Class LruCacheManager
- All Implemented Interfaces:
Cache,CacheManager
When the capacity is reached, the least recently used entry is removed from the cache.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault cache size limit in number of entries. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Object identifier, Object entity, Descriptors descriptors) Adds the specified object into the shared session cache.voidclose()Closes the cache.booleancontains(Class<?> cls, Object identifier, Descriptor descriptor) Checks whether the cache contains data for the given entity.voidRemoves the data for entities of the specified class (and its subclasses) from the cache.voidRemoves the data for the given entity from the cache.voidRemoves the data for entities of the specified repository context from the cache.voidevictAll()Clears the cache.voidRemoves objects with (possibly) inferred attributes from the cache.<T> Tget(Class<T> cls, Object identifier, Descriptor descriptor) Gets entity with the specified identifier from the cache.getLoadStateDescriptor(Object instance) GetsLoadStateDescriptorthat is associated with the specified cached instance.voidsetInferredClasses(Set<Class<?>> inferredClasses) Set the inferred classes for this cache manager.
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYDefault cache size limit in number of entries.- See Also:
-
-
Method Details
-
add
Description copied from interface:CacheManagerAdds the specified object into the shared session cache.If the cache already contains an object with the specified identifier (and it is in the same repository context), it is replaced with the one passed as argument.
- Specified by:
addin interfaceCacheManager- Parameters:
identifier- Identifier of the specified objectentity- The object to be added into the cachedescriptors- Instance descriptors
-
get
Description copied from interface:CacheManagerGets entity with the specified identifier from the cache.The entity is searched for in the context specified by
descriptor. Thus all three conditions - class, identifier and descriptor must match to return a result.- Specified by:
getin interfaceCacheManager- Parameters:
cls- Class of the entityidentifier- Primary key of the entitydescriptor- Instance descriptor, contains info about repository context(s) and language tags- Returns:
- Entity with the specified primary key or
null
-
getLoadStateDescriptor
Description copied from interface:CacheManagerGetsLoadStateDescriptorthat is associated with the specified cached instance.- Specified by:
getLoadStateDescriptorin interfaceCacheManager- Parameters:
instance- Instance whose load state descriptor to retrieve- Returns:
- Load state descriptor,
nullif this cache does not contain the specified instance
-
evictInferredObjects
public void evictInferredObjects()Description copied from interface:CacheManagerRemoves objects with (possibly) inferred attributes from the cache.This should be called when changes in the ontology may influence inference results.
- Specified by:
evictInferredObjectsin interfaceCacheManager
-
setInferredClasses
Description copied from interface:CacheManagerSet the inferred classes for this cache manager.Entities from inferred classes are special in that when anything in the ontology changes, they have to be evicted from the cache, since they are reasoned and their attributes may change.
- Specified by:
setInferredClassesin interfaceCacheManager- Parameters:
inferredClasses- Set of inferred classes
-
close
public void close()Description copied from interface:CacheManagerCloses the cache.- Specified by:
closein interfaceCacheManager
-
contains
Description copied from interface:CacheChecks whether the cache contains data for the given entity. -
evict
Description copied from interface:CacheRemoves the data for the given entity from the cache. -
evict
Description copied from interface:CacheRemoves the data for entities of the specified class (and its subclasses) from the cache.This method removes the entities from all available contexts.
-
evict
Description copied from interface:CacheRemoves the data for entities of the specified repository context from the cache. -
evictAll
public void evictAll()Description copied from interface:CacheClears the cache.
-