Welcome Guest, Not a member yet? Register   Sign In
Cache Dynamic Driver Load
#1

I want to use sometimes file and sometimes redis for cache. What is the way to activate sometimes redis cache and sometimes filecache according to the need in a controls?
Reply
#2

This solved my problem

PHP Code:
$config config('Cache');
 
$config->handler 'file';
 
$cache = \Config\Services::cache($config,false);
 if(! 
$foo $cache->get('foox'))
 {
 
$cache->save('foox', ['1','2'], 300);
 echo 
'cache false';
 }
 else
 {
 
print_r($foo);
 echo 
'cache true';
 } 
Reply
#3

The following code changes the value in the shared Config\Cache instance.

PHP Code:
$config config('Cache');
$config->handler 'file'

If you use two Cache service instances at the same time, the following code is better:
PHP Code:
$config = new \Config\Cache;
$config->handler 'file'
Reply




Theme © iAndrew 2016 - Forum software by © MyBB