From 832c6b2f62917b0c456c7a9f33f40d2ebeb75387 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 15:59:42 +0000 Subject: [PATCH] Use unique per board cache keys per [1] important when using shared memory from opcode caches with multiple boards on one server. [1] http://area51.phpbb.com/phpBB/viewtopic.php?p=201739#p201739 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9541 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_apc.php | 6 +++--- phpBB/includes/acm/acm_eaccelerator.php | 7 ++++--- phpBB/includes/acm/acm_memcache.php | 6 +++--- phpBB/includes/acm/acm_memory.php | 7 +++++-- phpBB/includes/acm/acm_xcache.php | 8 ++++---- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php index 14159f6826..ff24dfa0d8 100644 --- a/phpBB/includes/acm/acm_apc.php +++ b/phpBB/includes/acm/acm_apc.php @@ -57,7 +57,7 @@ class acm extends acm_memory */ function _read($var) { - return apc_fetch($var); + return apc_fetch($this->key_prefix . $var); } /** @@ -71,7 +71,7 @@ class acm extends acm_memory */ function _write($var, $data, $ttl = 2592000) { - return apc_store($var, $data, $ttl); + return apc_store($this->key_prefix . $var, $data, $ttl); } /** @@ -83,7 +83,7 @@ class acm extends acm_memory */ function _delete($var) { - return apc_delete($var); + return apc_delete($this->key_prefix . $var); } } diff --git a/phpBB/includes/acm/acm_eaccelerator.php b/phpBB/includes/acm/acm_eaccelerator.php index bce6c53f1c..7530043e83 100644 --- a/phpBB/includes/acm/acm_eaccelerator.php +++ b/phpBB/includes/acm/acm_eaccelerator.php @@ -49,6 +49,7 @@ class acm extends acm_memory foreach (eaccelerator_list_keys() as $var) { // @todo Check why the substr() + // @todo Only unset vars matching $this->key_prefix eaccelerator_rm(substr($var['name'], 1)); } @@ -76,7 +77,7 @@ class acm extends acm_memory */ function _read($var) { - $result = eaccelerator_get($var); + $result = eaccelerator_get($this->key_prefix . $var); if ($result === null) { @@ -106,7 +107,7 @@ class acm extends acm_memory // Serialize objects and make them easy to detect $data = (is_object($data)) ? $this->serialize_header . serialize($data) : $data; - return eaccelerator_put($var, $data, $ttl); + return eaccelerator_put($this->key_prefix . $var, $data, $ttl); } /** @@ -118,7 +119,7 @@ class acm extends acm_memory */ function _delete($var) { - return eaccelerator_rm($var); + return eaccelerator_rm($this->key_prefix . $var); } } diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 0544d23996..b22205578e 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -91,7 +91,7 @@ class acm extends acm_memory */ function _read($var) { - return $this->memcache->get($var); + return $this->memcache->get($this->key_prefix . $var); } /** @@ -105,7 +105,7 @@ class acm extends acm_memory */ function _write($var, $data, $ttl = 2592000) { - return $this->memcache->set($var, $data, $this->flags, $ttl); + return $this->memcache->set($this->key_prefix . $var, $data, $this->flags, $ttl); } /** @@ -117,7 +117,7 @@ class acm extends acm_memory */ function _delete($var) { - return $this->memcache->delete($var); + return $this->memcache->delete($this->key_prefix . $var); } } diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index 85e7a7b9d7..c7b5d34a47 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -22,6 +22,8 @@ if (!defined('IN_PHPBB')) */ class acm_memory { + var $key_prefix; + var $vars = array(); var $is_modified = false; @@ -34,9 +36,10 @@ class acm_memory */ function acm_memory() { - global $phpbb_root_path; + global $phpbb_root_path, $dbname, $table_prefix; - $this->cache_dir = $phpbb_root_path . 'cache/'; + $this->cache_dir = $phpbb_root_path . 'cache/'; + $this->key_prefix = md5($dbname, $table_prefix) . '_'; if (!isset($this->extension) || !extension_loaded($this->extension)) { diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php index 5b4ecd68d8..9cb8eae272 100644 --- a/phpBB/includes/acm/acm_xcache.php +++ b/phpBB/includes/acm/acm_xcache.php @@ -62,7 +62,7 @@ class acm extends acm_memory */ function _read($var) { - return xcache_get($var); + return xcache_get($this->key_prefix . $var); } /** @@ -76,7 +76,7 @@ class acm extends acm_memory */ function _write($var, $data, $ttl = 2592000) { - return xcache_set($var, $data, $ttl); + return xcache_set($this->key_prefix . $var, $data, $ttl); } /** @@ -88,7 +88,7 @@ class acm extends acm_memory */ function _delete($var) { - return xcache_unset($var); + return xcache_unset($this->key_prefix . $var); } /** @@ -101,7 +101,7 @@ class acm extends acm_memory function _isset($var) { // Most caches don't need to check - return xcache_isset($var); + return xcache_isset($this->key_prefix . $var); } }