support memcache out of the box

firebus - December 5, 2007 - 01:17
Project:Advanced cache
Version:5.x-1.6
Component:Code
Category:task
Priority:normal
Assigned:firebus
Status:needs review
Description

when using memcache, advcache should not serialize anything before calling cache_set, nor does it need to unserialize on cache_get.

#1

firebus - December 25, 2007 - 21:01

i'm using lines like the following:

$map = module_exists('memcache') ? $cache->data : unserialize($cache_data);

however, i think it would be nicer if memcache set a variable on install like 'serialized_cache' that we could query, in case there are other caches that also handle serialization themselves. maybe that's a little too precious, since D6 is about to be released with better handling for various cache backend serialization requirements...

#2

firebus - September 25, 2008 - 00:49
Status:active» needs review

i decided to create new, memcache-aware advcache_serialize and advcache_unserialize functions in advcache.module

and replaced all advcache-related calls to serialize and unserialize in the patched modules (currently only block, comment, node, taxonomy since that's all we've currently got working)

i have tested this slightly.

this is pretty minor and straightforward, and won't do anything at all if you're not running memcache.

let me know what you think.

AttachmentSize
197893.advcache.patch 805 bytes
197893.core_.patch 7.85 KB

#3

tomchuk - November 3, 2008 - 22:19

Correct me if I'm wrong, but enabling the memcache module (module_exists('memcache')) does not necessarily mean that cache data will be unserialized (especially since memcache.module is blank). I think it would be safer to check the cache_inc variable as in the attached patch.

AttachmentSize
advcache.module.patch 760 bytes

#4

firebus - November 16, 2008 - 06:38

iirc, memcache patches the default includes/cache.inc

this is so that, having patched the other core modules that memcache removes serialize() calls from, you can still disable the memcache functionality if you want to without unpatching.

so i still think it makes more sense to check module_exists('memcache'), than to check the settings variables...

#5

neclimdul - November 19, 2008 - 19:09

firebus, no it requires you use a different cache include setup in your settings.php,

Check the INSTALLATION.txt or scroll halfway down the project page to the colored block to see how this happens.

So actually checking the variable is probably the right solution.

#6

firebus - November 19, 2008 - 19:22

sigh.

take a look at the patch file.

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/memcache/pa...

you'll see, towards the top, that cache.inc is modified.

cache.inc is modified in such a way that, having patched it, you no longer want to make calls to serialize and unserialize outside of cache.inc.

yes, having installed memcache, you need to use one of the replacements for cache.inc to get the memcache functionality.

but, whether you're using one of the memcache.inc or the patched cache.inc, you still want to avoid calling serialize and unserialize.

checking module_exists('memcache') is not perfect, but it is better than checking the value of the cache settings variable.

 
 

Drupal is a registered trademark of Dries Buytaert.