For scalable caching when working with distributed IT systems, it is advisable to use distributed caches (Redis Cluster, Memcached Cluster). They support sharding, replication, and can dynamically balance the load across nodes.
The caching layer is implemented on top of a neutral client API. When the load in the cluster changes, nodes are automatically added or removed (auto-scaling).
Example: dynamically adapting Redis Cluster using a client that automatically discovers new nodes.
import rediscluster rc = rediscluster.RedisCluster(startup_nodes=[{"host": "127.0.0.1", "port": "7000"}]) rc.set('key', 'value')
Key features:
Does Memcached in cluster mode provide node failure resilience with data preservation?
No. Memcached does not preserve data upon restart or node failure. For persistence, it's better to use Redis.
Is it possible to cache data that changes very frequently (e.g., with a real lifespan of < 1 second)?
This is inefficient — managing old versions will be harder, and often it is better not to cache such objects at all.
Will invalid cache (stale cache) affect data integrity?
It may. A forced invalidation mechanism (e.g., via pub/sub or an event mechanism) should be implemented to reduce the risk of desynchronization.