I have been implementing cache . Works fine!, but durations seems to be not working. The time I have files are not lasting till that time . May be i could be wrong, I am creating user-wise caches, Please let me know best practices.
My Code follows :
//config/app.php
’Cache’ => [
‘default’ => [
‘className’ => ‘File’,
‘path’ => CACHE,
‘url’ => env(‘CACHE_DEFAULT_URL’, null),
],
‘short’ => [
‘className’ => ‘File’,
‘duration’ => ‘+60 minutes’,
‘path’ => CACHE,
‘prefix’ => ‘cake_short_’
],
/**
* Configure the cache used for general framework caching.
* Translation cache files are stored with this configuration.
* Duration will be set to '+1 year' in bootstrap.php when debug = false
* If you set 'className' => 'Null' core cache will be disabled.
*/
'_cake_core_' => [
'className' => 'File',
'prefix' => 'myapp_cake_core_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+2 minutes',
'url' => env('CACHE_CAKECORE_URL', null),
],
I have created a component called short copied from the Docs :
Below is the code that i used to create cache :
Cache::write(“data_$user[0]”, $data,‘short’);
This works fine file is created corresponding to the logged in user. But after few minutes it is deleted (May be 2 minutes).
Is there any mistake i am making ?