Discuz does not support the use of multiple groups of memcache, so we need to modify the code:
Discuz does not support the use of multiple groups of memcache, so we need to modify the code:
1234567891011121314151617181920212223242526272829303132 |
// Modify the public configuration file bbs/config/config_global.php $ _ config ['Memory '] ['memcache'] ['server'] = 'true '; $ _ config ['Memory '] ['memcache'] ['host'] [] = '2017. 168.1.1 '; $ _ config ['Memory'] ['memcache'] ['host'] [] = '2017. 168.1.2 '; // $ _ config ['Memory'] ['memcache'] ['server'] = 'localhost '; // $ _ config ['Memory '] ['memcache'] ['port'] = 11211; $ _ config ['Memory '] ['memcache'] ['pconnect'] = 1; $ _ config ['Memory '] ['memcache'] ['timeout'] = 1; // repair Modify discuz memcache class bbs/source/class/class_memcache.php functioninit ($ config) {if (! Empty ($ config ['server']) {$ this-> obj = newMemcache (); if ($ config ['pconnect ']) {$ I = 1; foreach ($ config ['host'] as $ one_host) {if ($ I = 1) {$ connect =@$ this-> obj-> pconnect ($ one_host, 11211);} else {$ connect =@ $ this-> obj-> addServer ($ one_host, 11211);} $ I ++ ;} // $ connect =@ $ this-> obj-> pconnect ($ config ['server'], $ config ['port']); // The else {$ connect =@ this-> obj-> connect ($ config ['Server'], $ config ['port']);} $ this-> enable = $ connect? True: false ;}} |
Use discuz memcache
1234567891011 |
Require_oncelibfile ('class/memcac'); @ brief dediscuz_root. '. /config/config_global.php '; // Get $ m = newdiscuz_memcache (); $ m-> init ($ _ config ['Memory'] ['memcache']); $ mail = "5991168@qc.com"; $ userinfo = $ m-> get (md5 ($ email); // write $ md5_name = md5 ($ email ); $ m-> set ($ md5_name, $ userinfo, MEMCACHE_COMPRESSED, time () + 43200 ); |
Discuz stores session by memcache
// Modify the configuration file php. ini
Php_value [session. save_handler] = memcached
Php_value [session. save_path] = 192.168.1.1: 11211