Provides various official and user-released code examples. For code reference, you are welcome to learn. redis is stored in plaintext by default. To add security requirements, you must add author certification to redis, v3.2.3 Library \ Think \ Cache \ Driver \ Redis. class. php and Library \ Think \ Session \ Driver \ Redis. class. additional settings are required for php code.
Add the last three lines to the constructor.
Public function _ construct ($ options = array ()){
If (! Extension_loaded ('redis ')){
E (L ('_ NOT_SUPPORT _'). ': redis ');
}
$ Data_redis_db = C ('redis _ db ');
$ Options = array_merge (array (
'Host' => C ('redis _ host ')? : '127. 0.0.1 ',
'Port' => C ('redis _ port ')? 6379,
'Timeout' => C ('data _ cache_timeout ')? : False,
'Persistent' => false,
'Auth' => C ('redis _ auth ')? C ('redis _ auth'): false,
'Db' => empty ($ data_redis_db )? 0: $ data_redis_db,
), $ Options );
$ This-> options = $ options;
$ This-> options ['expire '] = isset ($ options ['expire'])? $ Options ['expire ']: C ('data _ CACHE_TIME ');
$ This-> options ['prefix'] = isset ($ options ['prefix'])? $ Options ['prefix']: C ('data _ cache_prefix ');
$ This-> options ['length'] = isset ($ options ['length'])? $ Options ['length']: 0;
$ Func = $ options ['persistent']? 'Pconnect ': 'connect ';
$ This-> handler = new \ Redis;
$ Options ['timeout'] === false?
$ This-> handler-> $ func ($ options ['host'], $ options ['Port']):
$ This-> handler-> $ func ($ options ['host'], $ options ['Port'], $ options ['timeout']);
// Add code, set redis security, and add authentication Password
If (isset ($ options ['auth']) & $ options ['auth']) {
$ This-> handler-> auth ($ options ['auth']);
}
}
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB