Class DefaultEntityCache

  • All Implemented Interfaces:
    EntityCache

    public class DefaultEntityCache
    extends java.lang.Object
    implements EntityCache
    This is the default EntityCache for Morphia
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Boolean exists​(Key<?> k)
      Looks for a Key in the cache
      void flush()
      Clears the cache
      <T> T getEntity​(Key<T> k)
      Returns the entity for a Key
      <T> T getProxy​(Key<T> k)
      Returns a proxy for the entity for a Key
      void notifyExists​(Key<?> k, boolean exists)
      Notifies the cache of the existence of a Key
      <T> void putEntity​(Key<T> k, T t)
      Adds an entity to the cache
      <T> void putProxy​(Key<T> k, T t)
      Adds a proxy to the cache
      EntityCacheStatistics stats()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultEntityCache

        public DefaultEntityCache()
    • Method Detail

      • exists

        public java.lang.Boolean exists​(Key<?> k)
        Description copied from interface: EntityCache
        Looks for a Key in the cache
        Specified by:
        exists in interface EntityCache
        Parameters:
        k - the Key to search for
        Returns:
        true if the Key is found
      • flush

        public void flush()
        Description copied from interface: EntityCache
        Clears the cache
        Specified by:
        flush in interface EntityCache
      • getEntity

        public <T> T getEntity​(Key<T> k)
        Description copied from interface: EntityCache
        Returns the entity for a Key
        Specified by:
        getEntity in interface EntityCache
        Type Parameters:
        T - the type of the entity
        Parameters:
        k - the Key to search for
        Returns:
        the entity
      • getProxy

        public <T> T getProxy​(Key<T> k)
        Description copied from interface: EntityCache
        Returns a proxy for the entity for a Key
        Specified by:
        getProxy in interface EntityCache
        Type Parameters:
        T - the type of the entity
        Parameters:
        k - the Key to search for
        Returns:
        the proxy
      • notifyExists

        public void notifyExists​(Key<?> k,
                                 boolean exists)
        Description copied from interface: EntityCache
        Notifies the cache of the existence of a Key
        Specified by:
        notifyExists in interface EntityCache
        Parameters:
        k - the Key
        exists - true if the Key represents an existing entity
      • putEntity

        public <T> void putEntity​(Key<T> k,
                                  T t)
        Description copied from interface: EntityCache
        Adds an entity to the cache
        Specified by:
        putEntity in interface EntityCache
        Type Parameters:
        T - the type of the entity
        Parameters:
        k - the Key of the entity
        t - the entity
      • putProxy

        public <T> void putProxy​(Key<T> k,
                                 T t)
        Description copied from interface: EntityCache
        Adds a proxy to the cache
        Specified by:
        putProxy in interface EntityCache
        Type Parameters:
        T - the type of the entity
        Parameters:
        k - the Key of the entity
        t - the proxy