MemcacheSession Class Reference
[Memcache]
Redirect session to write to Memcache. More...
Public Member Functions |
|
close () | |
Close a session. |
|
destroy ($key) | |
Delete a session. |
|
gc ($lifetime) | |
Delete outdated sessions. |
|
open ($save_path, $session_name) | |
Open a session. |
|
read ($key) | |
Load session data from xcache.
|
|
write ($key, $value) | |
Write session data to XCache. |
|
Protected Member Functions |
|
create_key ($key) |
Detailed Description
Redirect session to write to Memcache.
Memcache(d) extension already comes with a session handler build in, so if you want to use that, rather than this implementation, set constant APP_MEMCACHE_STORE_SESSIONS to FALSE in your config files.
Definition at line 12 of file session.memcache.impl.php.
Member Function Documentation
MemcacheSession::close | ( | ) |
Close a session.
Implements ISessionHandler.
Definition at line 23 of file session.memcache.impl.php.
00023 { 00024 //Note that for security reasons the Debian and Ubuntu distributions of 00025 //php do not call _gc to remove old sessions, but instead run /etc/cron.d/php*, 00026 //which check the value of session.gc_maxlifetime in php.ini and delete the session 00027 //files in /var/lib/php*. This is all fine, but it means if you write your own 00028 //session handlers you'll need to explicitly call your _gc function yourself. 00029 //A good place to do this is in your _close function 00030 00031 // Since Memcache takes care of life time, no gc is needed 00032 //$this->gc(ini_get('session.gc_maxlifetime')); 00033 return true; 00034 }
MemcacheSession::create_key | ( | $ | key | ) | [protected] |
Definition at line 81 of file session.memcache.impl.php.
00081 { 00082 return 'g$s' . Config::get_url(Config::URL_DOMAIN) . '_' . $key; 00083 }
MemcacheSession::destroy | ( | $ | key | ) |
Delete a session.
Implements ISessionHandler.
Definition at line 69 of file session.memcache.impl.php.
00069 { 00070 GyroMemcache::delete($this->create_key($key)); 00071 }
MemcacheSession::gc | ( | $ | lifetime | ) |
Delete outdated sessions.
Implements ISessionHandler.
Definition at line 76 of file session.memcache.impl.php.
MemcacheSession::open | ( | $ | save_path, | |
$ | session_name | |||
) |
Open a session.
Implements ISessionHandler.
Definition at line 16 of file session.memcache.impl.php.
MemcacheSession::read | ( | $ | key | ) |
Load session data from xcache.
Implements ISessionHandler.
Definition at line 39 of file session.memcache.impl.php.
00039 { 00040 // Write and Close handlers are called after destructing objects since PHP 5.0.5 00041 // Thus destructors can use sessions but session handler can't use objects. 00042 // So we are moving session closure before destructing objects. 00043 register_shutdown_function('session_write_close'); 00044 $key = $this->create_key($key); 00045 00046 $ret = GyroMemcache::get($key); 00047 if ($ret === false) { 00048 $ret = ''; 00049 } 00050 return $ret; 00051 }
MemcacheSession::write | ( | $ | key, | |
$ | value | |||
) |
Write session data to XCache.
Implements ISessionHandler.
Definition at line 56 of file session.memcache.impl.php.
00056 { 00057 try { 00058 GyroMemcache::set($this->create_key($key), $value, ini_get('session.gc_maxlifetime')); 00059 return true; 00060 } 00061 catch(Exception $ex) { 00062 return false; 00063 } 00064 }
The documentation for this class was generated from the following file:
- contributions/cache.memcache/session.memcache.impl.php