Fix for r47482: put the RELEASE-NOTES entry in the "bug fixes" section and not the...
[mediawiki.git] / includes / MemcachedSessions.php
blobe3bcea1b027f1f93541da77a3034b7931e27bb98
1 <?php
2 /**
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
9 * @file
10 * @ingroup Cache
13 /**
14 * @todo document
16 function memsess_key( $id ) {
17 return wfMemcKey( 'session', $id );
20 /**
21 * @todo document
23 function memsess_open( $save_path, $session_name ) {
24 # NOP, $wgMemc should be set up already
25 return true;
28 /**
29 * @todo document
31 function memsess_close() {
32 # NOP
33 return true;
36 /**
37 * @todo document
39 function memsess_read( $id ) {
40 global $wgMemc;
41 $data = $wgMemc->get( memsess_key( $id ) );
42 if( ! $data ) return '';
43 return $data;
46 /**
47 * @todo document
49 function memsess_write( $id, $data ) {
50 global $wgMemc;
51 $wgMemc->set( memsess_key( $id ), $data, 3600 );
52 return true;
55 /**
56 * @todo document
58 function memsess_destroy( $id ) {
59 global $wgMemc;
60 $wgMemc->delete( memsess_key( $id ) );
61 return true;
64 /**
65 * @todo document
67 function memsess_gc( $maxlifetime ) {
68 # NOP: Memcached performs garbage collection.
69 return true;
72 session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc' );