modelsCache
配置如下
$di->set('modelsCache',function()use($config){$cache=newPhalcon\Cache\Backend\Redis(xx,xx);return$cache;});
在注入服务时候,配置参数index
可选择指定库存储,查看API看到有个setOptions
函数,试图远行下面代码
想从当前db0
,切换到db1
,但是所有数据都存到db0
了,没有切换,应该怎么做才能随时换库??
$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');
自己封装redis的操作类