Added a configuration option to set a default lifetime on cache saves

This commit is contained in:
Andy Miller
2014-11-27 23:00:11 -07:00
parent ea4690db3f
commit a66ce64171
2 changed files with 5 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ cache:
method: file # Method to check for updates in pages: file|folder|none
driver: auto # One of: auto|file|apc|xcache|memcache|wincache
prefix: 'g' # Cache prefix string (prevents cache conflicts)
lifetime: 86400 # Lifetime of cached data in seconds (0 = infinite)
twig:
cache: true # Set to true to enable twig caching

View File

@@ -154,6 +154,10 @@ class Cache extends Getters
public function save($id, $data, $lifetime = null)
{
if ($this->enabled) {
if ($lifetime == null) {
$lifetime = $this->config->get('system.cache.lifetime') ?: null;
}
$this->driver->save($id, $data, $lifetime);
}
}