Hey Alex,
Based on your findings, is it possible that your Redis cache implementation doesn’t support event-triggered invalidation? Since Groups finds a valid cache entry for post counts that is not correct and you notice the counts to be wrong over time, then I think that the invalidation strategy being used is only time-based, meaning that the contents will be emptied after a set period of time.
Kind regards,
George
Hey @gtsiokos,
We’re using this plugin: https://github.com/rhubarbgroup/redis-cache/ with AWS Elasticache (Redis 7.1) with no special options. Should be a fairly standard WP + Redis setup given the popularity of that plugin.
If you have any pointers as to how Groups clears/updates the counts I’m all ears, I can try and troubleshoot directly.
Thanks!
Alex
Hey Alex,
The counts are adjusted in the function you already found here and the cache contents are checked using the WP Cache API that’s why I mentioned earlier if and how does the OC you’re using invalidate the cache contents.
Perhaps it would be useful if you ask the OC developer on their caching strategy because since there is data found in the cache, then either something missing on the cache setup, or the data won’t invalidate when it should, according to your findings.
Kind regards,
George
Hey @gtsiokos,
What I’m suspecting is that the Groups cache entry for the wp_count_posts override is never cleared/invalidated at all.
Unless the expiry is expressly scheduled by passing a TTL with wp_cache_set (4th argument, which doesn’t seem to be used in the Groups_Cache implementation at all) or calling wp_cache_delete on the entry, which the core implementation does, it won’t ever be cleared or updated.
The default WP_Object_Cache implementation doesn’t persist across pageloads so that’s fine. However Redis and Memcached are both persistent so with the way the Groups_Cache class is implemented currently, any value will persist across pageloads forever until it is expressly modified/deleted.
Hope this helps,
Alex
Hey Alex,
Just to be sure I’ll try to replicate the setup locally on a test server. If there’s anything specific about the setup of OC plugin that I need to keep in mind, please let me know.
For the counts I wouldn’t use a TTL expiry because an event-driven expiry has a bigger significance in this case, but a test will show us what can be going wrong with the cache contents.
Kind regards,
George
Plugin Author
Kento
(@proaktion)
@alexl75 Using the latest release and from tests this seems to be resolved so I’m marking this thread accordingly. But should the issue still persist on your side, please let me know.