X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FCache%2FProfilerCache.php;h=7c4802077ab07d99b1ae9db724854f34425fa109;hb=ee8689cc899beecaf0943ac175550a7fb49cf199;hp=04271e7c69a2323dc6d54570557d3208a28be987;hpb=d56bd28a0762bb5ee293e2e944bdee5df9d24692;p=friendica.git diff --git a/src/Core/Cache/ProfilerCache.php b/src/Core/Cache/ProfilerCache.php index 04271e7c69..7c4802077a 100644 --- a/src/Core/Cache/ProfilerCache.php +++ b/src/Core/Cache/ProfilerCache.php @@ -1,8 +1,26 @@ . + * + */ namespace Friendica\Core\Cache; -use Friendica\Core\Cache; use Friendica\Core\System; use Friendica\Util\Profiler; @@ -11,10 +29,10 @@ use Friendica\Util\Profiler; * * It is using the decorator pattern (@see */ -class ProfilerCache implements ICacheDriver, IMemoryCacheDriver +class ProfilerCache implements ICache, IMemoryCache { /** - * @var ICacheDriver The original cache driver + * @var ICache The original cache driver */ private $cache; @@ -23,7 +41,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver */ private $profiler; - public function __construct(ICacheDriver $cache, Profiler $profiler) + public function __construct(ICache $cache, Profiler $profiler) { $this->cache = $cache; $this->profiler = $profiler; @@ -38,7 +56,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver $return = $this->cache->getAllKeys($prefix); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } @@ -52,7 +70,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver $return = $this->cache->get($key); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } @@ -60,13 +78,13 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver /** * {@inheritDoc} */ - public function set($key, $value, $ttl = Cache::FIVE_MINUTES) + public function set($key, $value, $ttl = Duration::FIVE_MINUTES) { $time = microtime(true); $return = $this->cache->set($key, $value, $ttl); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } @@ -80,7 +98,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver $return = $this->cache->delete($key); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } @@ -94,7 +112,7 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver $return = $this->cache->clear($outdated); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } @@ -102,14 +120,14 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver /** * {@inheritDoc} */ - public function add($key, $value, $ttl = Cache::FIVE_MINUTES) + public function add($key, $value, $ttl = Duration::FIVE_MINUTES) { - if ($this->cache instanceof IMemoryCacheDriver) { + if ($this->cache instanceof IMemoryCache) { $time = microtime(true); $return = $this->cache->add($key, $value, $ttl); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } else { @@ -120,14 +138,14 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver /** * {@inheritDoc} */ - public function compareSet($key, $oldValue, $newValue, $ttl = Cache::FIVE_MINUTES) + public function compareSet($key, $oldValue, $newValue, $ttl = Duration::FIVE_MINUTES) { - if ($this->cache instanceof IMemoryCacheDriver) { + if ($this->cache instanceof IMemoryCache) { $time = microtime(true); $return = $this->cache->compareSet($key, $oldValue, $newValue, $ttl); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } else { @@ -140,16 +158,24 @@ class ProfilerCache implements ICacheDriver, IMemoryCacheDriver */ public function compareDelete($key, $value) { - if ($this->cache instanceof IMemoryCacheDriver) { + if ($this->cache instanceof IMemoryCache) { $time = microtime(true); $return = $this->cache->compareDelete($key, $value); - $this->profiler->saveTimestamp($time, 'cache', System::callstack()); + $this->profiler->saveTimestamp($time, 'cache'); return $return; } else { return false; } } + + /** + * {@inheritDoc} + */ + public function GetName() + { + return $this->cache->getName() . ' (with profiler)'; + } }