Interface RenderingCacheService<T extends Serializable>
- Type Parameters:
T- the parameter of the class
- All Known Implementing Classes:
DefaultRenderingCacheService
public interface RenderingCacheService<T extends Serializable>
Service to cache
ItemModel data representation for rendering.
The type T can be represented by any Data or Model type.-
Method Summary
Modifier and TypeMethodDescriptionbooleanVerifies whether the cache is enabled or not.cacheOrElse(ItemModel item, Supplier<T> converter) Methods takes theItemModel, verifies that theSerializablerepresentation is cached and returns it.Returns cachedSerializable.Retrieves the key that must be used to cacheSerializable.voidPuts theSerializableinto the cache using provided key.
-
Method Details
-
cacheEnabled
boolean cacheEnabled()Verifies whether the cache is enabled or not.- Returns:
- true if cache is enabled, false otherwise
-
get
Returns cachedSerializable.- Parameters:
key- the key used to retrieve cachedSerializable- Returns:
- optional cached
Serializable.
-
put
Puts theSerializableinto the cache using provided key.- Parameters:
key- the key used to saveSerializableitem- theSerializablethat must be cached.
-
getKey
Retrieves the key that must be used to cacheSerializable. The key is retrieved byItemModel.- Parameters:
item- theItemModelfor which to retrieve the key.- Returns:
- the key
-
cacheOrElse
Methods takes theItemModel, verifies that theSerializablerepresentation is cached and returns it. If the item is not in the cache the converter is called andSerializablerepresentation is saved into the cache.- Parameters:
item- theItemModelto cache.converter- the converter to use if theItemModelis not in the cache.- Returns:
- the
Serializablerepresentation for rendering.
-