modelscache配置如下
<code>$di->set('modelsCache', function () use ($config) {
$cache = new Phalcon\Cache\Backend\Redis(xx, xx);
return $cache;
});</code>在注入服务时候,配置参数 index可选择指定库存储,查看 API 看到有个 setOptions 函数,试图远行下面代码
想从当前 db0,切换到 db1,但是所有数据都存到 db0 了,没有切换,应该怎么做才能随时换库??
<code>$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');</code>modelscache配置如下
<code>$di->set('modelsCache', function () use ($config) {
$cache = new Phalcon\Cache\Backend\Redis(xx, xx);
return $cache;
});</code>在注入服务时候,配置参数 index可选择指定库存储,查看 API 看到有个 setOptions 函数,试图远行下面代码
想从当前 db0,切换到 db1,但是所有数据都存到 db0 了,没有切换,应该怎么做才能随时换库??
<code>$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');</code>
自己封装redis的操作类
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号