diff --git a/MongoDBCachePool.php b/MongoDBCachePool.php index dad9c09..13e99c0 100644 --- a/MongoDBCachePool.php +++ b/MongoDBCachePool.php @@ -18,6 +18,7 @@ /** * @author Tobias Nyholm + * @author Magnus Nordlander */ class MongoDBCachePool extends AbstractCachePool { @@ -34,6 +35,13 @@ public function __construct(Collection $collection) $this->collection = $collection; } + /** + * @param Manager $manager + * @param string $database + * @param string $collection + * + * @return Collection + */ public static function createCollection(Manager $manager, $database, $collection) { $collection = new Collection($manager, $database, $collection); @@ -42,23 +50,29 @@ public static function createCollection(Manager $manager, $database, $collection return $collection; } + /** + * {@inheritdoc} + */ protected function fetchObjectFromCache($key) { $object = $this->collection->findOne(['_id' => $key]); if (!$object || !isset($object->data)) { - return [false, null]; + return [false, null, []]; } if (isset($object->expiresAt)) { if ($object->expiresAt < time()) { - return [false, null]; + return [false, null, []]; } } - return [true, unserialize($object->data)]; + return [true, unserialize($object->data), []]; } + /** + * {@inheritdoc} + */ protected function clearAllObjectsFromCache() { $this->collection->deleteMany([]); @@ -66,6 +80,9 @@ protected function clearAllObjectsFromCache() return true; } + /** + * {@inheritdoc} + */ protected function clearOneObjectFromCache($key) { $this->collection->deleteOne(['_id' => $key]); @@ -73,6 +90,9 @@ protected function clearOneObjectFromCache($key) return true; } + /** + * {@inheritdoc} + */ protected function storeItemInCache(CacheItemInterface $item, $ttl) { $object = [ diff --git a/composer.json b/composer.json index 0fdb42b..721ce45 100644 --- a/composer.json +++ b/composer.json @@ -26,13 +26,13 @@ "require": { "php": "^5.5|^7.0", "psr/cache": "^1.0", - "cache/adapter-common": "^0.2", - "cache/taggable-cache": "^0.3", + "cache/adapter-common": "^0.3", + "cache/taggable-cache": "^0.4", "mongodb/mongodb": "^1.0" }, "require-dev": { "phpunit/phpunit": "^4.0|^5.1", - "cache/integration-tests": "0.9.0" + "cache/integration-tests": "^0.9" }, "provide": { "psr/cache-implementation": "^1.0"