Retrieves a CacheLayer
instance which corresponds to the given
entity. CacheLayer
instance(s) may themselves be cached within
the value cache, but this is not part of the specification. Generically,
this method should return an instance of a working CacheLayer
implementation which can persist values relevant to the given entity in an
implementation-specific way. For example, the default implementation of this
interface (RAMCache
) returns a CacheLayer
which can
cache values in memory for a specific entity.
Typically, instances of the same implementation are returned for any
given entity (e.g. RAMCacheLayer
always returns an instance of
RAMValueCache
, regardless of the entity in question). It is
theoretically possible however to differentiate layers based on entity type
or even specific primary key value. I'm not sure why you would want to do
this, but there's nothing in the requirements which would prevent it. Code
which uses the result of this method should certainly be written to the
interface, rather than any specific implementation.
- Specified by:
createCacheLayer
in interface Cache
- Parameters:
entity
- TODO
- Returns:
- A layer which will handle caching of values as necessary for the
given entity.