X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FCache%2FCommandCache.php;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FCache%2FCommandCache.php;h=39661d526d7c8fffd6572ceed0b1e315272f3d79;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/drush/drush/src/Cache/CommandCache.php b/vendor/drush/drush/src/Cache/CommandCache.php new file mode 100644 index 000000000..39661d526 --- /dev/null +++ b/vendor/drush/drush/src/Cache/CommandCache.php @@ -0,0 +1,64 @@ +cacheBackend = $cacheBackend; + } + + /** + * Test for an entry from the cache + * @param string $key + * @return boolean + */ + public function has($key) + { + $cacheItem = $this->cacheBackend->get($key); + return $this->valid($cacheItem); + } + /** + * Get an entry from the cache + * @param string $key + * @return array + */ + public function get($key) + { + $cacheItem = $this->cacheBackend->get($key); + if (!$this->valid($cacheItem)) { + return []; + } + // TODO: FileCache::get() should just return the + // data element, not the entire cacheItem. Then we + // could make it implement SimpleCacheInterface & do + // away with this adapter class. + return $cacheItem->data; + } + /** + * Store an entry in the cache + * @param string $key + * @param array $data + */ + public function set($key, $data) + { + $this->cacheBackend->set($key, $data); + } + + protected function valid($cacheItem) + { + return is_object($cacheItem) && isset($cacheItem->data); + } +}