22 ms·
Great story, thanks for sharing. I wanted to ask a quick question about something: > Refreshing caches automatically How do people usually handle this? Is thi
by wasd 9y ago
Great story, thanks for sharing. I wanted to ask a quick question about something:
> Refreshing caches automatically
How do people usually handle this? Is this something done on the application layer or database layer? Where is the cache stored?
- owenmarshall 9y agoCaches could be stored in the database in a materialized view, in an external service like memcache or redis, or even in the application itself. Expiry can take a few different forms. Some caches have a defined space and use a replacement scheme like "fill the cache up, then remove the least recently accessed value". Some don't have defined sizes but instead remove entries based on timestamps (cache for n minutes). Some depend on invalidation messages from the application. It all depends on the applications needs. The most important thing to remember is that caching means your system becomes inherently a distributed one. State can become split across multiple sources, the cache can return stale data, invalidation might not happen when you expect, ... That's fine, but you have to program accordingly.