I am using this code in production environment and if i was not the one that rolled this patch i would have set this to RTBC, ala NR it is :).

This patch enables more granular key prefix control on per bin level. I also updated README.txt with example how to use this new feature. Some whitespaces were also stripped from line endings which make this patch a little bigger but overall code cleaner.

cheers.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

litwol’s picture

One comment still referenced 'memcache_key_prefix' versus the new 'default_key_prefix' string.

litwol’s picture

Status: Needs review » Needs work

To avoid breaking backward compatability, i think i'll change the default key index to 'memcache_key_prefix' and support both array and single prefix setting. that way with next module update absolutely nothing will break.

litwol’s picture

Assigned: Unassigned » litwol
litwol’s picture

Assigned: litwol » Unassigned
Status: Needs work » Needs review
FileSize
4.2 KB

Attached file features the following:
1) granular control of per-bin key prefixes
2) default key prefix for bins that did not specify own key prefix
3) maintain backward compatability for sites that still use single global prefix
4) updated README.txt to include example of pre-bin prefix

litwol’s picture

Status: Needs review » Reviewed & tested by the community

Ive been using this on my sites for a long time now without any problems. I'd appreciate it if this patch would be committed. Thanks.

catch’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.44 KB

#966338: Support key prefix by bin was duplicate, also had a more up-to-date patch than here.

There are whitespace changes in litwol's patch that are unrelated to the changes here, also the patch doesn't meet code style:

+  if ( is_array($prefix) ) { //allow for granular memcache key-bin prefixes with default fallback

For example.

Uploading the patch from the duplicate here, haven't reviewed that one yet so leaving at CNR.

litwol’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
FileSize
5.1 KB

I've updated patch for D7 as well as simplified the default key configuration (removed redundant "memcache_default_key_prefix"). README.txt updated as well.

litwol’s picture

FileSize
5.39 KB

Uploaded wrong patch (sorries!).

This one also fixes inconsistent urlencoding if key was longer than 250 bytes.

litwol’s picture

FileSize
5.08 KB

Wow. for reasons unknown chrome on windows urlencoded my patch O_O. here's attempt 2.

ogi’s picture

subscribe

pounard’s picture

Opened #1324812: Unify cache bin prefix: proposal to unified convention, I'd really like to see Memcache being well integrated with other cache backends. If my proposal ends up being adopted, you'll need to rewrite this particular patch to fit with.

bmhaskar’s picture

Has anyone tested this patch with Drupal 6?

bmhaskar’s picture

Version: 7.x-1.x-dev » 6.x-1.10
FileSize
1.9 KB

This is the modified patch as per the latest version of the memcache module. It supports three type of usage i.e. single key prefix for all the beans (default behavior), specific key prefix per bin, and also the default key prefix for other bins but a separate one for specific bin. Its based on comment#9.

thedavidmeister’s picture

Patch in #13 rerolled for git/makefiles + 6.x-1.10 memcache.

thedavidmeister’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Ah geez, so glad that worked. I was using Domain Access and had a cache prefix for each domain so that views, etc.. wouldn't "bleed" from one domain into another.

Without the ability to set a different preset per bin (something cacherouter does out of the box PS :P) I was seeing users with a Content Profile node updating the node in one domain and not seeing the update in the other domain. Flushing memcache would sync the profile across all domains.

Clearly, to handle multisite setups correctly you need to be able to set per-bin whether the cache is to be shared by all instances of the site or to be split.

Thanks again for the patch :)

Jeremy’s picture

Status: Reviewed & tested by the community » Needs work
markpavlitski’s picture

I've re-rolled the patch from #14 against latest 7.x-dev, tidied it up according to the coding standards, simplified slightly, and documented the feature in README.txt.

Edit: Please ignore

markpavlitski’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
FileSize
1.64 KB

Fixed elseif issue in #17.

Edit: Please ignore

markpavlitski’s picture

Version: 6.x-1.10 » 6.x-1.x-dev
Status: Needs work » Needs review
FileSize
2.63 KB

Re-roll and tidy up of patch in #14 against 6.x-dev, with documentation added to README.txt.

markpavlitski’s picture

I've ported the patch from #19 to 7.x, simplified slightly, and documented the feature in README.txt.

reubenavery’s picture

Looks good, thanks.

But why do this, and not employ DatabaseConnection::tablePrefix? Seems to me like the need for this would be to mirror database prefixes (or lack thereof)

fago’s picture

Issue summary: View changes
FileSize
1.61 KB

I guess new features would go into 7.x first, so setting back to 7.x

Also, I've re-rolled and simplified the patch a bit. Patch works for me, please review.

markpavlitski’s picture

Category: Task » Feature request
Priority: Major » Normal

@fago Looks like the tags got messed up during the d.o migration. Fyi, the patch in #20 is for 7.x.

@reubenavery I don't like the idea of using tablePrefix. It's one use-case for this functionality, but there are others too. This way users can make their own decision.

I'm lowering the priority as this doesn't seem like a major issue to me.

markpavlitski’s picture

I've just noticed the simplified patch in #22 doesn't handle the condition where there is no default prefix specified.

For example the configuration below will result in a hyphen prefix for all other keys, and throws Notice: Undefined index: default in dmemcache_key() multiple times per page load.

$conf['memcache_key_prefix'] = array(
  'cache_bootstrap' => 'cb',
  'cache_path' => 'cp',
);

The patch from #20 doesn't have this issue, so I've just rerolled it against latest head.

fago’s picture

I've just noticed the simplified patch in #22 doesn't handle the condition where there is no default prefix specified.

That has been by purpose as I thought 'default' is required. Howsoever, the documentation should probably be clear on that.

daceej’s picture

Updated the patch from #24 against the latest version.

  • Jeremy committed 7e9bc9e on 7.x-1.x
    Issue #467226 by litwol, markpavlitski, bmhaskar, thedavidmeister, fago...
Jeremy’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)

8 years in the making; sorry for the delay committing this. I tried to better clarify the documentation. Could be ported to 6, should be ported to 8.