Skip to content

Commit ff2ec2f

Browse files
committed
Tagging bugfix and updated tests to ^0.9
1 parent 0a3d663 commit ff2ec2f

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

MongoDBCachePool.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
/**
2020
* @author Tobias Nyholm <[email protected]>
21+
* @author Magnus Nordlander
2122
*/
2223
class 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 = [

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
"require": {
2727
"php": "^5.5|^7.0",
2828
"psr/cache": "^1.0",
29-
"cache/adapter-common": "^0.2",
30-
"cache/taggable-cache": "^0.3",
29+
"cache/adapter-common": "^0.3",
30+
"cache/taggable-cache": "^0.4",
3131
"mongodb/mongodb": "^1.0"
3232
},
3333
"require-dev": {
3434
"phpunit/phpunit": "^4.0|^5.1",
35-
"cache/integration-tests": "0.9.0"
35+
"cache/integration-tests": "^0.9"
3636
},
3737
"provide": {
3838
"psr/cache-implementation": "^1.0"

0 commit comments

Comments
 (0)