1818
1919/**
2020 * @author Tobias Nyholm <[email protected] > 21+ * @author Magnus Nordlander
2122 */
2223class MongoDBCachePool extends AbstractCachePool
2324{
@@ -34,6 +35,13 @@ public function __construct(Collection $collection)
3435 $ this ->collection = $ collection ;
3536 }
3637
38+ /**
39+ * @param Manager $manager
40+ * @param string $database
41+ * @param string $collection
42+ *
43+ * @return Collection
44+ */
3745 public static function createCollection (Manager $ manager , $ database , $ collection )
3846 {
3947 $ collection = new Collection ($ manager , $ database , $ collection );
@@ -42,37 +50,49 @@ public static function createCollection(Manager $manager, $database, $collection
4250 return $ collection ;
4351 }
4452
53+ /**
54+ * {@inheritdoc}
55+ */
4556 protected function fetchObjectFromCache ($ key )
4657 {
4758 $ object = $ this ->collection ->findOne (['_id ' => $ key ]);
4859
4960 if (!$ object || !isset ($ object ->data )) {
50- return [false , null ];
61+ return [false , null , [] ];
5162 }
5263
5364 if (isset ($ object ->expiresAt )) {
5465 if ($ object ->expiresAt < time ()) {
55- return [false , null ];
66+ return [false , null , [] ];
5667 }
5768 }
5869
59- return [true , unserialize ($ object ->data )];
70+ return [true , unserialize ($ object ->data ), [] ];
6071 }
6172
73+ /**
74+ * {@inheritdoc}
75+ */
6276 protected function clearAllObjectsFromCache ()
6377 {
6478 $ this ->collection ->deleteMany ([]);
6579
6680 return true ;
6781 }
6882
83+ /**
84+ * {@inheritdoc}
85+ */
6986 protected function clearOneObjectFromCache ($ key )
7087 {
7188 $ this ->collection ->deleteOne (['_id ' => $ key ]);
7289
7390 return true ;
7491 }
7592
93+ /**
94+ * {@inheritdoc}
95+ */
7696 protected function storeItemInCache (CacheItemInterface $ item , $ ttl )
7797 {
7898 $ object = [
0 commit comments