您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Phalcon 框架,redis 如何切换库

2024/2/22 11:00:43发布23次查看
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');

回复内容: 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的操作类
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product