ModelsCache configuration: {code ...} during service injection, you can specify the database storage by configuring the index parameter. you can see that the API has a setOptions function, and try to switch the following code from the current db0 to db1, but all the data is stored in db0 and there is no switchover. what should I do...
modelsCache
The configuration is as follows:
$di->set('modelsCache', function () use ($config) { $cache = new Phalcon\Cache\Backend\Redis(xx, xx); return $cache;});
Configure parameters during service injectionindex
You can select the specified library storage to view the API.setOptions
Function, trying to code below a remote line
Todb0
, Switchdb1
But all data is storeddb0
No switchover. how can I change the database at any time ??
$this->modelsCache->save('data_in_db0','value');$opt=$this->modelsCache->getOptions();$opt['index']=1;$this->modelsCache->setOptions($opt);$this->modelsCache->save('data_in_db1','value');
Reply content:
modelsCache
The configuration is as follows:
$di->set('modelsCache', function () use ($config) { $cache = new Phalcon\Cache\Backend\Redis(xx, xx); return $cache;});
Configure parameters during service injectionindex
You can select the specified library storage to view the API.setOptions
Function, trying to code below a remote line
Todb0
, Switchdb1
But all data is storeddb0
No switchover. how can I change the database at any time ??
$this->modelsCache->save('data_in_db0','value');$opt=$this->modelsCache->getOptions();$opt['index']=1;$this->modelsCache->setOptions($opt);$this->modelsCache->save('data_in_db1','value');
Self-encapsulated redis operations