diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
commit | ca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch) | |
tree | ec04cc15b867bc21eedca904cea9af0254531a11 /includes/cache/MemcachedSessions.php | |
parent | a22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff) |
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook
* Use only css to hide our menu bar when printing
Diffstat (limited to 'includes/cache/MemcachedSessions.php')
-rw-r--r-- | includes/cache/MemcachedSessions.php | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/includes/cache/MemcachedSessions.php b/includes/cache/MemcachedSessions.php new file mode 100644 index 00000000..36733595 --- /dev/null +++ b/includes/cache/MemcachedSessions.php @@ -0,0 +1,98 @@ +<?php +/** + * This file gets included if $wgSessionsInMemcache is set in the config. + * It redirects session handling functions to store their data in memcached + * instead of the local filesystem. Depending on circumstances, it may also + * be necessary to change the cookie settings to work across hostnames. + * See: http://www.php.net/manual/en/function.session-set-save-handler.php + * + * @file + * @ingroup Cache + */ + +/** + * Get a cache key for the given session id. + * + * @param $id String: session id + * @return String: cache key + */ +function memsess_key( $id ) { + return wfMemcKey( 'session', $id ); +} + +/** + * Callback when opening a session. + * NOP: $wgMemc should be set up already. + * + * @param $save_path String: path used to store session files, unused + * @param $session_name String: session name + * @return Boolean: success + */ +function memsess_open( $save_path, $session_name ) { + return true; +} + +/** + * Callback when closing a session. + * NOP. + * + * @return Boolean: success + */ +function memsess_close() { + return true; +} + +/** + * Callback when reading session data. + * + * @param $id String: session id + * @return Mixed: session data + */ +function memsess_read( $id ) { + global $wgMemc; + $data = $wgMemc->get( memsess_key( $id ) ); + if( ! $data ) return ''; + return $data; +} + +/** + * Callback when writing session data. + * + * @param $id String: session id + * @param $data Mixed: session data + * @return Boolean: success + */ +function memsess_write( $id, $data ) { + global $wgMemc; + $wgMemc->set( memsess_key( $id ), $data, 3600 ); + return true; +} + +/** + * Callback to destroy a session when calling session_destroy(). + * + * @param $id String: session id + * @return Boolean: success + */ +function memsess_destroy( $id ) { + global $wgMemc; + + $wgMemc->delete( memsess_key( $id ) ); + return true; +} + +/** + * Callback to execute garbage collection. + * NOP: Memcached performs garbage collection. + * + * @param $maxlifetime Integer: maximum session life time + * @return Boolean: success + */ +function memsess_gc( $maxlifetime ) { + return true; +} + +function memsess_write_close() { + session_write_close(); +} + |