Created
May 7, 2016 08:49
-
-
Save davidlukac/81bb8bb4486bc1b9f11dc9c664bef656 to your computer and use it in GitHub Desktop.
Drupal 7 - memcache module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/dmemcache.inc b/dmemcache.inc | |
index b19c9c2..e279144 100644 | |
--- a/dmemcache.inc | |
+++ b/dmemcache.inc | |
@@ -394,6 +394,11 @@ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) { | |
if ($collect_stats) { | |
foreach ($multi_stats as $key => $value) { | |
+ // If we are using the broken version of memcache library, we need to | |
+ // prepend the key prefix to get correct statistics for get/set_multiple. | |
+ if (variable_get('memcache_broken_lib', FALSE)) { | |
+ $key = variable_get('memcache_key_prefix', '') . $key; | |
+ } | |
$multi_stats[$key] = isset($results[$key]) ? TRUE : FALSE; | |
} | |
} | |
@@ -406,6 +411,15 @@ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) { | |
if (is_object($value) && !empty($value->multi_part_data)) { | |
$value = _dmemcache_get_pieces($value->data, $value->cid, $bin, $mc); | |
} | |
+ // If we are using the broken version of memcache library, we need to remove | |
+ // the prefix from the stored key, because it's there twice, by mistake. | |
+ // Otherwise get/set_multiple operation doesn't work correctly. | |
+ if (variable_get('memcache_broken_lib', FALSE)) { | |
+ $prefix = variable_get('memcache_key_prefix', ''); | |
+ if (substr($key, 0, strlen($prefix)) == $prefix) { | |
+ $key = substr($key, strlen($prefix)); | |
+ } | |
+ } | |
$cid_results[$cid_lookup[$key]] = $value; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For certain versions of
memcache
library,get_multiple
function doesn't work, because of bug in handling key prefixes. This patch should fix that.