$di->set('modelscache', function () use ($config) { $cache = new phalcon\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');
回复内容: modelscache配置如下
$di->set('modelscache', function () use ($config) { $cache = new phalcon\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的操作类
