Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#26 | memcache-bin-prefix-467226-26.patch | 1.6 KB | daceej |
#24 | memcache-bin-prefix-467226-24.patch | 1.73 KB | markpavlitski |
#22 | d7_memcache_prefix_by_bin.patch | 1.61 KB | fago |
#20 | memcache-bin-prefix-467226-20.patch | 1.63 KB | markpavlitski |
#17 | memcache-bin-prefix-467226-17.patch | 1.64 KB | markpavlitski |
Comments
Comment #1
litwol CreditAttribution: litwol commentedOne comment still referenced 'memcache_key_prefix' versus the new 'default_key_prefix' string.
Comment #2
litwol CreditAttribution: litwol commentedTo 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.
Comment #3
litwol CreditAttribution: litwol commentedComment #4
litwol CreditAttribution: litwol commentedAttached 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
Comment #5
litwol CreditAttribution: litwol commentedIve 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.
Comment #6
catch#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:
For example.
Uploading the patch from the duplicate here, haven't reviewed that one yet so leaving at CNR.
Comment #7
litwol CreditAttribution: litwol commentedI've updated patch for D7 as well as simplified the default key configuration (removed redundant "memcache_default_key_prefix"). README.txt updated as well.
Comment #8
litwol CreditAttribution: litwol commentedUploaded wrong patch (sorries!).
This one also fixes inconsistent urlencoding if key was longer than 250 bytes.
Comment #9
litwol CreditAttribution: litwol commentedWow. for reasons unknown chrome on windows urlencoded my patch O_O. here's attempt 2.
Comment #10
ogi CreditAttribution: ogi commentedsubscribe
Comment #11
pounardOpened #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.
Comment #12
bmhaskar CreditAttribution: bmhaskar commentedHas anyone tested this patch with Drupal 6?
Comment #13
bmhaskar CreditAttribution: bmhaskar commentedThis 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.
Comment #14
thedavidmeister CreditAttribution: thedavidmeister commentedPatch in #13 rerolled for git/makefiles + 6.x-1.10 memcache.
Comment #15
thedavidmeister CreditAttribution: thedavidmeister commentedAh 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 :)
Comment #16
Jeremy CreditAttribution: Jeremy commentedPlease follow http://drupal.org/coding-standards
Comment #17
markpavlitski CreditAttribution: markpavlitski commentedI'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
Comment #18
markpavlitski CreditAttribution: markpavlitski commentedFixed elseif issue in #17.Edit: Please ignore
Comment #19
markpavlitski CreditAttribution: markpavlitski commentedRe-roll and tidy up of patch in #14 against 6.x-dev, with documentation added to README.txt.
Comment #20
markpavlitski CreditAttribution: markpavlitski commentedI've ported the patch from #19 to 7.x, simplified slightly, and documented the feature in README.txt.
Comment #21
reubenavery CreditAttribution: reubenavery commentedLooks 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)
Comment #22
fagoI 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.
Comment #23
markpavlitski CreditAttribution: markpavlitski commented@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.
Comment #24
markpavlitski CreditAttribution: markpavlitski commentedI'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.The patch from #20 doesn't have this issue, so I've just rerolled it against latest head.
Comment #25
fagoThat has been by purpose as I thought 'default' is required. Howsoever, the documentation should probably be clear on that.
Comment #26
daceej CreditAttribution: daceej at Third and Grove commentedUpdated the patch from #24 against the latest version.
Comment #28
Jeremy CreditAttribution: Jeremy at Tag1 Consulting commented8 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.