Php 缓存组件中的默认生存期

Php 缓存组件中的默认生存期,php,caching,symfony,symfony-components,Php,Caching,Symfony,Symfony Components,我需要从缓存适配器配置默认生存期,但发生了一些奇怪的事情,以下操作不起作用!?:/ use Symfony\Component\Cache\Adapter\FilesystemAdapter; // in seconds; applied to cache items that don't define their own lifetime // 0 means to store the cache items indefinitely (i.e. until the files are

我需要从缓存适配器配置默认生存期,但发生了一些奇怪的事情,以下操作不起作用!?:/

use Symfony\Component\Cache\Adapter\FilesystemAdapter;

// in seconds; applied to cache items that don't define their own lifetime  
// 0 means to store the cache items indefinitely (i.e. until the files are deleted)
$cache = new FilesystemAdapter('my_namespace', 5); // <-- default lifetime 5 seconds
$latestNews = $cache->getItem('latest_news');

if (!$latestNews->isHit()) {
    $news = ['title' => '...', 'createdAt' => (new \DateTime())->format('Y-m-d H:i:s')];
    $cache->save($latestNews->set($news));
} else {
    $news = $latestNews->get();
}
参考文献

项目正确过期后5秒

我用
Symfony\Component\Cache\Adapter\ApcuAdapter
测试了这个问题,也出现了同样的问题


缓存适配器中的默认生存期(构造函数参数)会发生什么情况?我在这里遗漏了一些东西:/?

是一个影响3.1之前的框架版本的老问题


升级Symfony框架应该可以修复它。

检查您是否有一个带有此错误的旧版本是的,它是:)谢谢@Matteo
composer update
!我可以把评论作为答案发布,这样你就可以结束这个问题了吗?。。。或者升级缓存组件应该可以修复它;)
2147483647 <-- 2038-01-18 22:14:07 :/ ?
latest_news
a:2:{s:5:"title";s:3:"...";s:9:"createdAt";s:19:"2016-10-07 09:16:50";}
1475849350 <-- 2016-10-07 10:09:10 \o/ OK
latest_news
a:2:{s:5:"title";s:3:"...";s:9:"createdAt";s:19:"2016-10-07 10:09:05";}