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:

  1. Fetch the actual key names from the database using a SELECT LIKE query and then delete each of these entries from Memcache.
  2. Flush the memcache entries for the given table even if $cid is 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.

CommentFileSizeAuthor
#1 memcache.db_.inc-6.x-1.7-968882.patch377 byteshiddentao

Comments

hiddentao’s picture

StatusFileSize
new377 bytes

Patch attached.

hiddentao’s picture

Status: Patch (to be ported) » Needs review
hiddentao’s picture

Sorry, in the description I put the fixed version of the code. Here is the unpatched version of the code:

    if ($wildcard) {
      if ($cid == '*') {
        dmemcache_flush($table);
        db_query("TRUNCATE TABLE {". $table ."}");
      }
      else {
        db_query("DELETE FROM {". $table ."} WHERE cid LIKE '%s%%'", $cid);
      }
    }
jeremy’s picture

Status: Needs review » Closed (won't fix)

The memcache.db.inc file has been deprecated:
#961496: Deprecate memcache.db.inc

It is recommended that you instead use memcache.inc.

btopro’s picture

still 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.