Momento flush cache is a modern convenience
Flushing your cache doesn’t have to be slow or dangerous.
Momento customers have been telling us that a do-over is sometimes a good thing. But Mo the squirrel was feeling conflicted about the prospect of an entire cache going away. How quickly could a critter get back to their regular routine?! Faced with a serious product conundrum, we turned to our engineering team with bewilderment in our eyes and yelled, “WE NEED MAGIC!!”. And they said, “okay”.
Why would you flush a cache anyway?
A quick reset to get back to a known starting point can be helpful during development and also for integration and performance testing. Some production use cases involve a periodic bulk load of data into the cache from a fresh start. And yes, sometimes people make mistakes (either in the primary store or the cached data) and the fastest path to recovery is just to get rid of everything that’s already in the cache. When it’s a big enough mess, you just want it to go away—I heard about these “world is on fire” operational scenarios from a friend of a friend.
Without the capability to flush a cache, there are two options:
- Delete the original cache and replace it with a new one with the same name.
- Create a replacement cache, reconfigure all client software to use it instead, then delete the original.
Both options can be quite disruptive for live application traffic and generally they involve some onerous administrative effort. Momento’s lightning-fast control plane makes the first option seem somewhat reasonable—but Mo demanded that we meet a higher standard.
Flush, sanitize, get right back to work
The flush capability in many traditional caching solutions actually involves deleting all existing items over a period of time. How long? Well, that depends on how many items are present—as an O(N) time complexity operation it will take longer as your data grows—and you’ll see a significant jump in CPU consumption while it is working on this. In some cases, you might be able to swap out the caches on the fly—but you still have to burn the CPU to do the cleanup at some point (sooner rather than later if you want that memory back). Momento’s distributed architecture means that we’re able to fully flush your cache almost instantly—regardless of data volume. And you can have as many caches as you need—break out your keys as it makes most sense for your application! Clients don’t need to change anything, and you never have to worry about infrastructure effects like CPU load. This may seem like a subtle benefit, but it’s important to us at Momento because it’s meaningful for customers like Kevin Jones at Paramount:
We occasionally have the need to purge a set of keys from our cache. Before, in Redis, this was a very tedious process that could take an hour or more to avoid any downtime. Now, with our keys separated into namespaces, we can run a single command and the keys are flushed instantly.
As the one that used to have to do the manual flushes, I really appreciate all of the time that it’s saved me since Momento introduced the feature.
Kevin Jones, Paramount
The levers
The flush feature for Momento Cache is now available for use within the Momento CLI and in the .NET and Rust SDKs (coming in planned updates for Java, Node.js, Python, PHP, Ruby and Go).