I'm using the book module in my Drupal 6 installation and one of the features is the ability to re-order the pages within a book. The page re-ordering is done by adjusting the weights of the menu item links which come under the book root node's menu item. When saving the adjusted order on my memcache.db.inc-enabled site I get a success message yet the page ordering shown on the results page looks unchanged.
Digging deeper the culprit lies in here inside cache_clear_all() in memcache.db.inc:
if ($wildcard) {
dmemcache_flush($table);
if ($cid == '*') {
db_query("TRUNCATE TABLE {". $table ."}");
}
else {
db_query("DELETE FROM {". $table ."} WHERE cid LIKE '%s%%'", $cid);
}
}
As we can see if $wildcard is TRUE but $cid is not '*' then only the database cache data is deleted; the Memcache data is unchanged. This is incorrect behaviour.
We can't perform a LIKE query against Memcache so the available options are:
- Fetch the actual key names from the database using a SELECT LIKE query and then delete each of these entries from Memcache.
- Flush the memcache entries for the given table even if
$cidis not '*'.
I've opted for option 2 since it simpler to implement and moreover, can be applied as a solution to the pure-Memcaching cacheing solution too.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | memcache.db_.inc-6.x-1.7-968882.patch | 377 bytes | hiddentao |
Comments
Comment #1
hiddentao commentedPatch attached.
Comment #2
hiddentao commentedComment #3
hiddentao commentedSorry, in the description I put the fixed version of the code. Here is the unpatched version of the code:
Comment #4
jeremy commentedThe memcache.db.inc file has been deprecated:
#961496: Deprecate memcache.db.inc
It is recommended that you instead use memcache.inc.
Comment #5
btopro commentedstill getting similar behavior w/ outline designer (ajax'ed version of book) and memcache.inc. Turning memcache off completely helps, might just have to recommend not using it with the book module or mention there are issues.