From f17e9b4032544b3f8b58f9da382a76b164250640 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 17 Aug 2007 15:53:19 +0000 Subject: [PATCH] to allow other code (eg. the SyncML code from Horde) to open the eGW session, we use a first memcache key identical to the original memcache session handler (for the first junk/1MB) --- phpgwapi/inc/memcache.inc.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpgwapi/inc/memcache.inc.php b/phpgwapi/inc/memcache.inc.php index 7ace5c3f4e..c4e4c75f4c 100644 --- a/phpgwapi/inc/memcache.inc.php +++ b/phpgwapi/inc/memcache.inc.php @@ -4,7 +4,10 @@ * * Fixes a problem of the buildin session handler of the memcache pecl extension, * which can NOT work with sessions > 1MB. This handler splits the session-data - * in 1MB junk, so memcache can handle them. + * in 1MB junk, so memcache can handle them. For the first junk we use an identical + * key (just the session-id) as the original memcache session handler. For the further + * junks we add -2, -3, ... so other code (eg. the SyncML code from Horde) can + * open the session, if it's size is < 1MB. * * To enable it, you need to set session.save_handler to 'memcache' and * session.save_path to 'tcp://host:port[,tcp://host2:port,...]', @@ -44,8 +47,7 @@ function egw_memcache_read($id) { global $egw_memcache_obj; - $id = 'sess-'.$_REQUEST['domain'].'-'.$id; - for($data=false,$n=0; ($read = $egw_memcache_obj->get($id.'-'.$n)); ++$n) + for($data=false,$n=0; ($read = $egw_memcache_obj->get($id.($n?'-'.$n:''))); ++$n) { $data .= $read; } @@ -62,10 +64,9 @@ function egw_memcache_write($id, $sess_data) { $lifetime = 600; } - $id = 'sess-'.$GLOBALS['egw_info']['user']['domain'].'-'.$id; for($n=$i=0,$len=_bytes($sess_data); $i < $len; $i += MEMCACHED_MAX_JUNK,++$n) { - if (!$egw_memcache_obj->set($id.'-'.$n,_cut_bytes($sess_data,$i,MEMCACHED_MAX_JUNK),0,$lifetime)) return false; + if (!$egw_memcache_obj->set($id.($n?'-'.$n:''),_cut_bytes($sess_data,$i,MEMCACHED_MAX_JUNK),0,$lifetime)) return false; } return true; } @@ -97,8 +98,7 @@ function egw_memcache_destroy($id) { global $egw_memcache_obj; - $id = 'sess-'.$_REQUEST['domain'].'-'.$id; - for($n=0; $egw_memcache_obj->delete($id.'-'.$n); ++$n) ; + for($n=0; $egw_memcache_obj->delete($id.($n?'-'.$n:'')); ++$n) ; return $n > 0; }