ContextualCache
Stores information temporarily to avoid unneeded network requests.
Unlike Cache, a contextual cache stores multiple values per identifier. The context decides which value is visible. Here are a few examples of context usage:
authentication information (different users see different values)
paging information (different values are returned depending on the requested page)
The main advantage of using this interface rather than using a compound key in Cache is that it is possible to expire a value for all contexts.
In all other regards (cache states, cache chaining…), this interface is identical to Cache. Cache can be seen as a specialization of this interface for the case where the context is Unit.
Parameters
The identifier used to request from the cache.
The context which differentiates between cache results.
The possible failures when requesting the cache.
The possible successful value when requesting the cache.
Functions
In-memory ContextualCache layer.
Tells the cache that the values it stores for the given id are out of date, no matter the context, and should be queried again the next time they are requested.
Tells the cache that the values it stores for the given ids are out of date, no matter the context, and should be queried again the next time they are requested.
Age-based ContextualCache expiration strategy.
Tells the cache that the values it stores for the given ids are out of date, and should be queried again the next time they are requested.
Forces the cache to accept the given values as more recent for their associated identifier than whatever was previously stored.