Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
fixed expiration support and removed duplicated tests of MongoDb adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-mabe committed Nov 29, 2015
1 parent d17414d commit c20124f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
7 changes: 1 addition & 6 deletions src/Storage/Adapter/MongoDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ protected function internalGetItem(& $normalizedKey, & $success = null, & $casTo

if ($result['expires']->sec < time()) {
$this->internalRemoveItem($normalizedKey);

return;
}
}
Expand Down Expand Up @@ -241,12 +240,8 @@ protected function internalGetCapabilities()
'supportedMetadata' => [
'_id',
],
'minTtl' => 0,
'maxTtl' => 0,
'minTtl' => 1,
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => false,
'expiredRead' => false,
'maxKeyLength' => 255,
'namespaceIsPrefix' => true,
]
Expand Down
33 changes: 0 additions & 33 deletions test/Storage/Adapter/MongoDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,4 @@ public function testSetOptionsNotMongoDbOptions()

$this->assertInstanceOf('\Zend\Cache\Storage\Adapter\MongoDbOptions', $this->_storage->getOptions());
}

public function testCachedItemsExpire()
{
$ttl = 2;
$key = 'foo';
$value = 'bar';

$this->_storage->getOptions()->setTtl($ttl);

$this->_storage->setItem($key, $value);

// wait for the cached item to expire
sleep($ttl * 2);

$this->assertNull($this->_storage->getItem($key));
}

public function testFlush()
{
$key1 = 'foo';
$key2 = 'key';
$value1 = 'bar';
$value2 = 'value';

$this->assertEquals([], $this->_storage->setItems([
$key1 => $value1,
$key2 => $value2,
]));

$this->assertTrue($this->_storage->flush());

$this->assertEquals([], $this->_storage->hasItems([$key1, $key2]));
}
}

0 comments on commit c20124f

Please sign in to comment.