Interface CacheManager

All Superinterfaces:
Cache
All Known Implementing Classes:
DisabledCacheManager, LruCacheManager, TtlCacheManager

public interface CacheManager extends Cache
This interface defines basic methods for accessing the shared live object cache.
  • Method Details

    • add

      void add(Object identifier, Object entity, Descriptors descriptors)
      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 object
      entity - The object to be added into the cache
      descriptors - Instance descriptors
    • get

      <T> T get(Class<T> cls, Object identifier, Descriptor descriptor)
      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 entity
      identifier - Primary key of the entity
      descriptor - Instance descriptor, contains info about repository context(s) and language tags
      Returns:
      Entity with the specified primary key or null
    • getLoadStateDescriptor

      LoadStateDescriptor<?> getLoadStateDescriptor(Object instance)
      Gets LoadStateDescriptor 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

      void setInferredClasses(Set<Class<?>> inferredClasses)
      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.