X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fsrc%2FCache%2FCacheBackendWrapper.php;fp=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fsrc%2FCache%2FCacheBackendWrapper.php;h=725e4cf5906388bf6a3caa52f296bb5ef9955345;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/devel/webprofiler/src/Cache/CacheBackendWrapper.php b/web/modules/contrib/devel/webprofiler/src/Cache/CacheBackendWrapper.php new file mode 100644 index 000000000..725e4cf59 --- /dev/null +++ b/web/modules/contrib/devel/webprofiler/src/Cache/CacheBackendWrapper.php @@ -0,0 +1,176 @@ +cacheDataCollector = $cacheDataCollector; + $this->cacheBackend = $cacheBackend; + $this->bin = $bin; + } + + /** + * {@inheritdoc} + */ + public function get($cid, $allow_invalid = FALSE) { + $cache = $this->cacheBackend->get($cid, $allow_invalid); + + if ($cache) { + $cacheCopy = new \StdClass(); + $cacheCopy->cid = $cache->cid; + $cacheCopy->expire = $cache->expire; + $cacheCopy->tags = $cache->tags; + + $this->cacheDataCollector->registerCacheHit($this->bin, $cacheCopy); + } + else { + $this->cacheDataCollector->registerCacheMiss($this->bin, $cid); + } + + return $cache; + } + + /** + * {@inheritdoc} + */ + public function getMultiple(&$cids, $allow_invalid = FALSE) { + $cidsCopy = $cids; + $cache = $this->cacheBackend->getMultiple($cids, $allow_invalid); + + foreach ($cidsCopy as $cid) { + if (in_array($cid, $cids)) { + $this->cacheDataCollector->registerCacheMiss($this->bin, $cid); + } + else { + $cacheCopy = new \StdClass(); + $cacheCopy->cid = $cache[$cid]->cid; + $cacheCopy->expire = $cache[$cid]->expire; + $cacheCopy->tags = $cache[$cid]->tags; + + $this->cacheDataCollector->registerCacheHit($this->bin, $cacheCopy); + } + } + + return $cache; + } + + /** + * {@inheritdoc} + */ + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { + return $this->cacheBackend->set($cid, $data, $expire, $tags); + } + + /** + * {@inheritdoc} + */ + public function setMultiple(array $items) { + return $this->cacheBackend->setMultiple($items); + } + + /** + * {@inheritdoc} + */ + public function delete($cid) { + return $this->cacheBackend->delete($cid); + } + + /** + * {@inheritdoc} + */ + public function deleteMultiple(array $cids) { + return $this->cacheBackend->deleteMultiple($cids); + } + + /** + * {@inheritdoc} + */ + public function deleteAll() { + return $this->cacheBackend->deleteAll(); + } + + /** + * {@inheritdoc} + */ + public function invalidate($cid) { + return $this->cacheBackend->invalidate($cid); + } + + /** + * {@inheritdoc} + */ + public function invalidateMultiple(array $cids) { + return $this->cacheBackend->invalidateMultiple($cids); + } + + /** + * {@inheritdoc} + */ + public function invalidateTags(array $tags) { + if ($this->cacheBackend instanceof CacheTagsInvalidatorInterface) { + $this->cacheBackend->invalidateTags($tags); + } + } + + /** + * {@inheritdoc} + */ + public function invalidateAll() { + return $this->cacheBackend->invalidateAll(); + } + + /** + * {@inheritdoc} + */ + public function garbageCollection() { + return $this->cacheBackend->garbageCollection(); + } + + /** + * {@inheritdoc} + */ + public function removeBin() { + return $this->cacheBackend->removeBin(); + } + +}