Package dev.morphia.mapping.cache
Interface EntityCache
-
- All Known Implementing Classes:
DefaultEntityCache
public interface EntityCache
A primarily internal class used by MorphiaIterator to track entities loaded from mongo to prevent multiple loads of objects when keys are seen multiple times in a query result.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Boolean
exists(Key<?> k)
Looks for a Key in the cachevoid
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 Keyvoid
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 cacheEntityCacheStatistics
stats()
-
-
-
Method Detail
-
exists
java.lang.Boolean exists(Key<?> k)
Looks for a Key in the cache- Parameters:
k
- the Key to search for- Returns:
- true if the Key is found
-
flush
void flush()
Clears the cache
-
getEntity
<T> T getEntity(Key<T> k)
Returns the entity for a Key- Type Parameters:
T
- the type of the entity- Parameters:
k
- the Key to search for- Returns:
- the entity
-
getProxy
<T> T getProxy(Key<T> k)
Returns a proxy for the entity for a Key- Type Parameters:
T
- the type of the entity- Parameters:
k
- the Key to search for- Returns:
- the proxy
-
notifyExists
void notifyExists(Key<?> k, boolean exists)
Notifies the cache of the existence of a Key- Parameters:
k
- the Keyexists
- true if the Key represents an existing entity
-
putEntity
<T> void putEntity(Key<T> k, T t)
Adds an entity to the cache- Type Parameters:
T
- the type of the entity- Parameters:
k
- the Key of the entityt
- the entity
-
putProxy
<T> void putProxy(Key<T> k, T t)
Adds a proxy to the cache- Type Parameters:
T
- the type of the entity- Parameters:
k
- the Key of the entityt
- the proxy
-
stats
EntityCacheStatistics stats()
- Returns:
- the stats for this cache
-
-