From 8987b0de0c3ab0dffc3b76c3b5a735cd96e8e5cf Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 11 Jul 2006 14:20:19 +0000 Subject: Make WP_Object_cache multi-blog aware git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@650 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/cache.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'wp-includes/cache.php') diff --git a/wp-includes/cache.php b/wp-includes/cache.php index 976a0b3..be573be 100644 --- a/wp-includes/cache.php +++ b/wp-includes/cache.php @@ -75,7 +75,23 @@ class WP_Object_Cache { return true; } + function key($key, $group) { + global $blog_id; + + if ( empty($group) ) + $group = 'default'; + + if (false !== array_search($group, $this->global_groups)) + $prefix = ''; + else + $prefix = $blog_id . ':'; + + return "$prefix$group:$key"; + } + + function add($id, $data, $group = 'default', $expire = '') { + $id = $this->key($id, $group); if (empty ($group)) $group = 'default'; @@ -86,6 +102,7 @@ class WP_Object_Cache { } function delete($id, $group = 'default', $force = false) { + $id = $this->key($id, $group); if (empty ($group)) $group = 'default'; @@ -116,6 +133,7 @@ class WP_Object_Cache { } function get($id, $group = 'default', $count_hits = true) { + $id = $this->key($id, $group); if (empty ($group)) $group = 'default'; @@ -272,6 +290,7 @@ class WP_Object_Cache { } function replace($id, $data, $group = 'default', $expire = '') { + $id = $this->key($id, $group); if (empty ($group)) $group = 'default'; @@ -282,6 +301,7 @@ class WP_Object_Cache { } function set($id, $data, $group = 'default', $expire = '') { + $id = $this->key($id, $group); if (empty ($group)) $group = 'default'; -- cgit