/** @var PruneableInterface|CacheInterface $cache */
$cache =
$this->
createSimpleCache();
$cache->
clear();
$cache->
set('foo', 'foo-val',
new \
DateInterval('PT05S'
));
$cache->
set('bar', 'bar-val',
new \
DateInterval('PT10S'
));
$cache->
set('baz', 'baz-val',
new \
DateInterval('PT15S'
));
$cache->
set('qux', 'qux-val',
new \
DateInterval('PT20S'
));
sleep(30
);
$cache->
prune();
$this->
assertTrue($this->
isPruned($cache, 'foo'
));
$this->
assertTrue($this->
isPruned($cache, 'bar'
));
$this->
assertTrue($this->
isPruned($cache, 'baz'
));
$this->
assertTrue($this->
isPruned($cache, 'qux'
));
$cache->
set('foo', 'foo-val'
);
$cache->
set('bar', 'bar-val',
new \
DateInterval('PT20S'
));
$cache->
set('baz', 'baz-val',
new \
DateInterval('PT40S'
));
$cache->
set('qux', 'qux-val',
new \
DateInterval('PT80S'
));
$cache->
prune();
$this->
assertFalse($this->
isPruned($cache, 'foo'
));