3 ms·
I prefer caching in memory, but a major limitation once you have more than one process is invalidation. It's really only easy to stuff you can cache and just ex
by fabian2k 2y ago
I prefer caching in memory, but a major limitation once you have more than one process is invalidation. It's really only easy to stuff you can cache and just expire on time, not if you need to invalidate it. At that point you need to communicate between your processes (or all of them need to listen to the DB for events).
- Elucalidavah 2y ago> need to listen to the DB for events You could store the key->version separately, and read the said version. If the cached version is lower, it's a cache miss. Of course, evicting something from cache (due to memory constraints) is a bit harder (or less efficient) in such setup.
- tombert 2y agoYeah, if you need to do things across processes then something like Redis or memcached might be necessary. The thing that bothers me is people adding it in places that don't make sense; I mentioned in a sibling thread that the I've seen people use it as a glorified global variable in stuff like Kafka streaming. Kafka's stuff is already partitioned, you likely don't gain anything from Redis compared to just keeping a local map, and at that point you can just use a Guava Cache and let it handle invalidation in-process.
- koolba 2y agoNot just across concurrent processes, but also serial ones. Externalizing a cache into something like Redis lets you bounce your process with no reload time. You can get around it for some things like web sessions with a signed cookie, but that opens up expiration and invalidation issue. But that doesn’t work for caching non trivial calculations or intermediate state. There’s a sweet spot for transitory persistence.
- blazing234 2y agoI think the crazy thing is people think redis is the only thing that catches in memory. You could throw a bunch of your production data in SSAS tabular and there you go you have an in memory cache. I've actually deployed that as a solution and the speed is crazy.
- Seattle3503 2y agoI wonder if there are language neutral alternatives to Infinispan.