The Fastest Redis Object Cache for WordPress
Following our very successful Translation Cache for WordPress and Redis Page Cache for WordPress plugins, we’re very excited to announce the most efficient implementation of object caching in existence!
Over the years, at Pressjitsu we’ve learned that object caching is very tricky. We’ve written about it several times like in our article about caching queries. This year, by analyzing performance profiles that our users have performed, we came to learn that there’s a lot that can be improved in Redis-based object caches.
Since object caching is not mandatory on our platform and users are free to decide for themselves whether they really need it or not, we have analyzed the performance footprint of Till Kurss’ Redis Cache and its predecessor Eric Mann’s Redis Object Cache. These were by far the most popular caches among our clients.
Till’s cache had a lot of improvement over Eric’s implementation in some cases, to the extent that full page caching is in the works. But both lacked a concern for lower-level performance. Redundant calls to
exits, the use of regular expressions, and the lack of other seemingly apparent shortcuts that could be taken.
But the most performance-oriented feature that all Redis object caches lack was cache preheating via an
mget call. We took Eric’s plugin as it was easy to work through with just the bare basic in there. Our preheating mechanism learns what keys are usually fetched as part of a request and fetches them in one single Redis call without unserializing them. This is many times faster than fetching the data in an ad hoc manner.
In the first preheating phase our cache merely remembers what is fetched in this request. As you can see above (disregard the
delete calls, they’re irrelevant in this case), we have 503 calls to
Redis::get. The second request is shown below:
The 503 calls to
Redis::get are replaced with one call to the multiget function. Any keys that the cache was unable to predict are fetched from Redis as per usual. We just saved 20x time on Redis call overheads! Isn’t that something? Other areas have been highly improved to reduce calls to the Redis server.
With the large overhaul test are critical. It’s all to easy to poison cache and preaheating layers with stale data. So we actually wrote the tests. And they’re not fake. Coverage is effectively full and we’re set on keeping it that way.
Check out our Redis Object Cache for WordPress implementation. It’s open-source and available for free download. It will become available in the official WordPress repository soon. Stay tuned for even more improvements.
Questions, problems, true stories? Reach out a email@example.com.
And join Pressjitsu to make your WordPress application feel lightweight again!