Was critical data stored only in the cache, or was it also duplicated in persistent storage?
AI answer
A cache should not be the only place where data that must not be lost is stored: it can be cleared, evicted due to limits, or lost in a failure. The source of truth should be persistent storage—for example, a database or object storage—and the cache should be recoverable from it. If consistency and freshness matter, define cache invalidation or refresh rules, an acceptable TTL, and behavior when the cache is unavailable. For data that is inherently temporary and can be lost, the cache can serve as the primary store, but this must be explicitly documented as a requirement rather than assumed.
Also asked at Коммит (Аутстафф на проект "Ростелекома")
- How to protect the system from creating multiple payments if the user presses the pay button many times?
- How is the N+1 query problem solved in ORM?
- What types of indexes are available in PostgreSQL?
- There are several services (2-3), and there is an end-to-end business scenario passing through all services. If an operation on one of the services in the middle or at the end fails, the system ends up in an inconsistent state. What methods can be used to achieve inter-service transactionality (either the entire scenario is applied, or none of it is), if each service has its own database?
- What databases have you worked with the most?
Similar questions
- Could you briefly explain the caching in this case: what was cached, and how did it help?
- How did you invalidate the cache?
- What happened if a particular Redis cache instance went down?
- Can we ensure data durability in Redis if the service crashes, so that we don't lose shopping carts?
- How was data distributed across Redis instances (sharding or full replication)?