I'd like to request the ability to clear prefixes at once. This is useful for certain setups where administrators access one instance of the site on a URL like admin.example.com, but regular users access the site on www.example.com. In my case, I am using different prefixes for each site, but would like to clear the same key on one site if it is cleared on the other. I've attached a patch that allows this.
To clear multiple prefixes at the same time, you just need to apply the patch and add the list of prefixes to be cleared to your settings.php:
$conf['memcache_prefix_clear_list'] = array('www', 'staging');
Comment | File | Size | Author |
---|---|---|---|
#12 | memcache-multiclear-d7-1084448-12.patch | 1.41 KB | jcfiala |
#8 | memcache-multiclear-d7-1084448-8.patch | 1.41 KB | jcfiala |
#7 | memcache-multiclear-d7-1084448-7.patch | 1.43 KB | jcfiala |
#6 | memcache-multiclear-d7-1084448-6.patch | 1.43 KB | jcfiala |
#4 | memcache-multiclear-d7-1084448-4.patch | 1.43 KB | jcfiala |
Comments
Comment #1
catchPatch isn't attached ;)
Comment #2
jtsnow CreditAttribution: jtsnow commentedDoh! Here it is.
Comment #3
catchComment #4
jcfiala CreditAttribution: jcfiala commentedI think this is a pretty good idea - we've just hit on a situation where we need the same sort of functionality.
Here's our patch, targeted at d7.
Comment #5
cyberswat CreditAttribution: cyberswat commentedIt's probably nit-picky, but I'd suggest something that doesn't use the empty() checks ... maybe something like the following would ultimately be more performant?
Comment #6
jcfiala CreditAttribution: jcfiala commentedAfter a bit of back and forth locally, here's an updated patch:
Comment #7
jcfiala CreditAttribution: jcfiala commentedAnd apparently I failed to hit save after making my changes...
Comment #8
jcfiala CreditAttribution: jcfiala commentedAnd apparently I am an idiot today.
Comment #9
cyberswat CreditAttribution: cyberswat commentedI like this approach because it explicitly sets the prefix passed in to NULL so that it can't be mistaken for a legitimate cache prefix and should perform marginally better.
Comment #10
marcingy CreditAttribution: marcingy commentedThe patch is for d7 so bumping to there to solve confusion.
Comment #11
cyberswat CreditAttribution: cyberswat commentedif ($prefix == NULL) {
should beif ($prefix === NULL) {
Comment #12
jcfiala CreditAttribution: jcfiala commentedUpdated the patch to reflect cyberswat's not in comment 12:
Comment #14
Jeremy CreditAttribution: Jeremy at Tag1 Consulting commentedSorry for the slow review.
I've rewritten the logic to use the existing prefix variable for maximum flexibility.
The feature is currently documented as follows: