<?php
namespace Engine\Cache; class Debug extends Dummy { public function set($key, $value, $expireTime=0) :void { if (is_array($value)) { $debugValue = sprintf("array(%d elements, %d bytes size)", count($value), strlen(serialize($value))); } elseif (is_object($value)) { $debugValue = sprintf("object(%s, %d bytes size)", get_class($value), strlen(serialize($value))); } else { $debugValue = $value; } \Engine\Debug\Dline::instance()->vprintf("{%function}('{%key}', {%value}, {%expireTime})", [ 'function' => __METHOD__, 'key' => $key, 'value' => $debugValue, 'expireTime' => $expireTime, ]); parent::set($key, $value, $expireTime); } public function get($key) { \Engine\Debug\Dline::instance()->vprintf("#>{%function}('{%key}')", [ 'function' => __METHOD__, 'key' => $key, ]); $value = parent::get($key); if (is_array($value)) { $debugValue = sprintf("array(%d elements, %d bytes size)", count($value), strlen(serialize($value))); } elseif (is_object($value)) { $debugValue = sprintf("object(%s, %d bytes size)", get_class($value), strlen(serialize($value))); } else { $debugValue = $value; } \Engine\Debug\Dline::instance()->vprintf("#<got {%value}", [ 'function' => __METHOD__, 'value' => $debugValue, ]); return $debugValue; } public function delete($key) :void { \Engine\Debug\Dline::instance()->vprintf("{%function}({%key})", [ 'function' => __METHOD__, 'key' => $key, ]); parent::delete($key); } public function flush() :bool { \Engine\Debug\Dline::instance()->vprintf("{%function}()", [ 'function' => __METHOD__, ]); return parent::flush(); } public function getInfo($key) { return parent::getInfo($key); } } 