Phalcon framework, how does redis switch databases?

Source: Internet
Author: User
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... modelsCacheThe configuration is as follows:

$di->set('modelsCache', function () use ($config) {    $cache = new Phalcon\Cache\Backend\Redis(xx, xx);    return $cache;});

Configure parameters during service injectionindexYou can select the specified library storage to view the API.setOptionsFunction, trying to code below a remote line
Todb0, Switchdb1But all data is storeddb0No 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:

modelsCacheThe configuration is as follows:

$di->set('modelsCache', function () use ($config) {    $cache = new Phalcon\Cache\Backend\Redis(xx, xx);    return $cache;});

Configure parameters during service injectionindexYou can select the specified library storage to view the API.setOptionsFunction, trying to code below a remote line
Todb0, Switchdb1But all data is storeddb0No 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.