Commit bed7066c authored by robertDouglass's avatar robertDouglass
Browse files

Finally, a memcache.inc that actually sets and gets all the potential cache...

Finally, a memcache.inc that actually sets and gets all the potential cache hits it is supposed to. This version is dependent on this patch: http://drupal.org/files/issues/cache_serialization_1.patch
parent 9621c2db
...@@ -230,7 +230,7 @@ function cache_get($key, $table = 'cache') { ...@@ -230,7 +230,7 @@ function cache_get($key, $table = 'cache') {
// If the data is permanent or we're not enforcing a minimum cache lifetime // If the data is permanent or we're not enforcing a minimum cache lifetime
// always return the cached data. // always return the cached data.
if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) { if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
$cache->data = db_decode_blob($cache->data); $cache->data = unserialize(db_decode_blob($cache->data));
} }
// If enforcing a minimum cache lifetime, validate that the data is // If enforcing a minimum cache lifetime, validate that the data is
// currently valid for this user before we return it by making sure the // currently valid for this user before we return it by making sure the
...@@ -243,7 +243,7 @@ function cache_get($key, $table = 'cache') { ...@@ -243,7 +243,7 @@ function cache_get($key, $table = 'cache') {
return 0; return 0;
} }
else { else {
$cache->data = db_decode_blob($cache->data); $cache->data = unserialize(db_decode_blob($cache->data));
} }
} }
return $cache; return $cache;
...@@ -296,9 +296,9 @@ function cache_get($key, $table = 'cache') { ...@@ -296,9 +296,9 @@ function cache_get($key, $table = 'cache') {
*/ */
function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) { function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
db_lock_table($table); db_lock_table($table);
db_query("UPDATE {%s} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid); db_query("UPDATE {%s} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $table, serialize($data), time(), $expire, $headers, $cid);
if (!db_affected_rows()) { if (!db_affected_rows()) {
@db_query("INSERT INTO {%s} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers); @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $table, $cid, serialize($data), time(), $expire, $headers);
} }
db_unlock_tables(); db_unlock_tables();
if ($expire === CACHE_PERMANENT && $headers === NULL) { if ($expire === CACHE_PERMANENT && $headers === NULL) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment