3 * This file gets included if $wgSessionsInMemcache is set in the config.
4 * It redirects session handling functions to store their data in memcached
5 * instead of the local filesystem. Depending on circumstances, it may also
6 * be necessary to change the cookie settings to work across hostnames.
7 * See: http://www.php.net/manual/en/function.session-set-save-handler.php
16 function memsess_key( $id ) {
17 return wfMemcKey( 'session', $id );
23 function memsess_open( $save_path, $session_name ) {
24 # NOP, $wgMemc should be set up already
31 function memsess_close() {
39 function memsess_read( $id ) {
41 $data = $wgMemc->get( memsess_key( $id ) );
42 if( ! $data ) return '';
49 function memsess_write( $id, $data ) {
51 $wgMemc->set( memsess_key( $id ), $data, 3600 );
58 function memsess_destroy( $id ) {
60 $wgMemc->delete( memsess_key( $id ) );
67 function memsess_gc( $maxlifetime ) {
68 # NOP: Memcached performs garbage collection.
72 session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc' );