: This article describes how php writes file sessions to memcache. For more information about PHP tutorials, see.
Get (self: session_key ($ PHPSESSID); if ($ val = false | $ val = null) {return false;} return $ val ;} public static function write ($ PHPSESSID, $ data) {$ method = $ data? 'Set': 'Replace '; return self: $ handler-> $ method (self: session_key ($ PHPSESSID), $ data, MEMCACHE_COMPRESSED, self :: $ lifetime);} public static function destroy ($ PHPSESSID) {return self ::$ handle-> delete (self: session_key ($ PHPSESSID ));} // memcache has a limited time and data is automatically destroyed. Therefore, you do not need to use the gc method public static function gc ($ lifetime) {return true;} // add a prefix to sessionID, avoid duplicate private static function session_key ($ PHPSESSID) {$ session_key = self: MS. $ PHPSESSID; return $ session_key; }}$ mem = new Memcache; $ mem-> connect ("localhost", 11211) or die ("cocould not connect"); MemSession :: start ($ mem );
The above describes how php writes file-type sessions to memcache, including some content. I hope my friends who are interested in PHP tutorials will be helpful.