Package cz.cvut.kbss.jopa.sessions.cache
Interface CacheManager
- All Superinterfaces:
Cache
- All Known Implementing Classes:
DisabledCacheManager
,LruCacheManager
,TtlCacheManager
This interface defines basic methods for accessing the shared live object cache.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Object identifier, Object entity, Descriptors descriptors) Adds the specified object into the shared session cache.void
close()
Closes the cache.void
Removes objects with (possibly) inferred attributes from the cache.<T> T
get
(Class<T> cls, Object identifier, Descriptor descriptor) Gets entity with the specified identifier from the cache.getLoadStateDescriptor
(Object instance) GetsLoadStateDescriptor
that is associated with the specified cached instance.void
setInferredClasses
(Set<Class<?>> inferredClasses) Set the inferred classes for this cache manager.
-
Method Details
-
add
Adds the specified object into the shared session cache.If the cache already contains object with the specified identifier (and it is in the same repository context), it is replaced with the one passed as argument.
- Parameters:
identifier
- Identifier of the specified objectentity
- The object to be added into the cachedescriptors
- Instance descriptors
-
get
Gets 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.- 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
GetsLoadStateDescriptor
that is associated with the specified cached instance.- Parameters:
instance
- Instance whose load state descriptor to retrieve- Returns:
- Load state descriptor,
null
if this cache does not contain the specified instance
-
evictInferredObjects
void evictInferredObjects()Removes objects with (possibly) inferred attributes from the cache.This should be called when changes in the ontology may influence inference results.
-
setInferredClasses
Set 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.
- Parameters:
inferredClasses
- Set of inferred classes
-
close
void close()Closes the cache.
-