Memcache itself has no built-in support for wildcard flushes. Both memcache and memcache_storage modules get around this by keeping track of each time cache_clear_all() is called with a wildcard pattern, incrementing a counter for the pattern being flushed, and using that count in a hash of the $cid value. Incrementing the count has the effect of changing the CID used for entries that match the wildcard pattern, causing new values to be cached/retrieved for those entries.
This works well. The problem is that both modules store the wildcard flush counts in the variable table. Since metatag module can execute a wildcard flush for just about every entity on the site, this variable can quickly become bloated. Right now on my site, this variable value is 4 MB long and takes 6 seconds to update.
This is probably a "won't fix" for Metatag. I still thought it was worth mentioning in the issue queue, since Memcache is extremely popular.
Comment | File | Size | Author |
---|---|---|---|
#13 | metatag-n2420489-13.patch | 2.06 KB | DamienMcKenna |
Comments
Comment #1
Les LimHere's a patch which absolutely should not be committed to Metatag, but does remove the wildcard flush by simplifying the CID used to cache each entity's metatags. This also removes all of the module's flexibility in generating different metatags in different entity contexts.
Comment #2
DamienMcKennaHow about this - restructure the caching so that all versions of an individual entity's data is cached in one larger object? That way it *could* do cache_clear_all("output:$entity_type:$entity_id", 'cache_metatag') without any problems.
Comment #3
DamienMcKennaComment #4
Les LimSure! I can work on that.
Comment #5
Les LimHere's a patch implementing #2. Each entity now maintains a single cache entry with the $cid pattern "output:$entity_type:$entity_id". That cache entry is a keyed array of metatag variants, where the key is full string returned by metatag_cache_default_cid_parts().
Comment #6
DamienMcKennaThat's excellent! Thanks Les!
I'll see about getting some folks to test it on their larger, multilingual and/or multi-revision sites, to see how well it works.
Comment #7
DamienMcKennaFYI I added a patch in #2474427: Drop the output cache to disable the output cache.
Comment #8
DamienMcKennaDefinitely need tests for this.
Comment #9
DamienMcKennaComment #10
DamienMcKennaComment #11
DamienMcKennaRerolled, still needs tests.
Comment #12
DamienMcKennaBecause it needs tests.
Comment #13
DamienMcKennaRerolled.
Comment #14
DamienMcKennaComment #15
DamienMcKennaComment #16
DamienMcKennaThe tests still pass, not sure what else needs to be tested?
Comment #17
DamienMcKennaComment #18
DamienMcKennaCommitted. Thanks!