You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
<?php
|
|
|
|
class Harmonious_Session_Handler_Memcached extends Harmonious_Session_Handler {
|
|
|
|
public function open( $savePath, $sessionName ) {
|
|
return(true);
|
|
}
|
|
|
|
public function close() {
|
|
return true;
|
|
}
|
|
|
|
public function read( $id ) {
|
|
$mc = $this->app->memcached;
|
|
$key = "php_session_file_". $id;
|
|
$ret = $mc->get($key);
|
|
if(!$ret['result']) return "";
|
|
else {
|
|
$maxlifetime = ini_get('session.gc_maxlifetime');
|
|
$mc->set($key, $ret['value'], $maxlifetime);
|
|
return (string) $ret['value'];
|
|
}
|
|
}
|
|
|
|
public function write( $id, $sessionData ) {
|
|
$mc = $this->app->memcached;
|
|
$key = "php_session_file_". $id;
|
|
$maxlifetime = ini_get('session.gc_maxlifetime');
|
|
$ret = $mc->set($key, $sessionData, $maxlifetime);
|
|
if ($ret['result']) return true;
|
|
else return(false);
|
|
}
|
|
|
|
public function destroy( $id ) {
|
|
$mc = $this->app->memcached;
|
|
$key = "php_session_file_". $id;
|
|
$mc->delete($key);
|
|
return(true);
|
|
}
|
|
|
|
public function gc( $maxLifetime ) {
|
|
return true;
|
|
}
|
|
}
|
|
?>
|
|
|