Policy-Based Cache Design
I would hide the caching implementation behind an ICache abstraction and represent expiration as a cache policy rather than scattering TTL values throughout the application. Different consumers can provide different policies. The cache implementation can then enforce absolute or sliding expiration consistently.
Separate cache abstraction from cache implementation.
Represent TTL and other behavior as explicit policies.
Support absolute and, where appropriate, sliding expiration.
Define cache invalidation rules and consistency expectations.
For distributed applications, consider a distributed cache rather than process-local memory.
Monitor hit rate, eviction rate, memory usage, and latency.