|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.cache.lookup.EntityLookupCache
public class EntityLookupCache
A cache for two-way lookups of database entities. These are characterized by having a unique key (perhaps a database ID) and a separate unique key that identifies the object. If no cache is given, then all calls are passed through to the backing DAO.
The keys must have good equals
and hashCode implementations and
must respect the case-sensitivity of the use-case.
All keys will be unique to the given cache region, allowing the cache to be shared between instances of this class.
Generics:
Nested Class Summary | |
---|---|
static interface |
EntityLookupCache.EntityLookupCallbackDAO
Interface to support lookups of the entities using keys and values. |
static class |
EntityLookupCache.EntityLookupCallbackDAOAdaptor
Adaptor for implementations that support immutable entities. |
Constructor Summary | |
---|---|
EntityLookupCache(EntityLookupCache.EntityLookupCallbackDAO entityLookup)
Construct the lookup cache without any cache. |
|
EntityLookupCache(org.alfresco.repo.cache.SimpleCache cache,
EntityLookupCache.EntityLookupCallbackDAO entityLookup)
Construct the lookup cache, using the default cache region . |
|
EntityLookupCache(org.alfresco.repo.cache.SimpleCache cache,
java.lang.String cacheRegion,
EntityLookupCache.EntityLookupCallbackDAO entityLookup)
Construct the lookup cache, using the given cache region. |
Method Summary | |
---|---|
void |
clear()
Cache-only operation: Remove all cache entries NOTE: This operation removes ALL entries for ALL cache regions. |
int |
deleteByKey(java.io.Serializable key)
Delete the entity associated with the given key. |
int |
deleteByValue(java.lang.Object value)
Delete the entity having the given value.. |
org.alfresco.util.Pair |
getByKey(java.io.Serializable key)
Find the entity associated with the given key. |
org.alfresco.util.Pair |
getByValue(java.lang.Object value)
Find the entity associated with the given value. |
java.io.Serializable |
getKey(java.io.Serializable valueKey)
Cache-only operation: Get the key for a given value key (note: not 'value' but 'value key'). |
org.alfresco.util.Pair |
getOrCreateByValue(java.lang.Object value)
Find the entity associated with the given value and create it if it doesn't exist. |
java.lang.Object |
getValue(java.io.Serializable key)
Cache-only operation: Get the value for a given key |
void |
removeByKey(java.io.Serializable key)
Cache-only operation: Remove all cache values associated with the given key. |
void |
removeByValue(java.lang.Object value)
Cache-only operation: Remove all cache values associated with the given value |
void |
setValue(java.io.Serializable key,
java.lang.Object value)
Cache-only operation: Update the cache's value |
int |
updateValue(java.io.Serializable key,
java.lang.Object value)
Update the entity associated with the given key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EntityLookupCache(EntityLookupCache.EntityLookupCallbackDAO entityLookup)
entityLookup
- the instance that is able to find and persist entitiespublic EntityLookupCache(org.alfresco.repo.cache.SimpleCache cache, EntityLookupCache.EntityLookupCallbackDAO entityLookup)
default cache region
.
cache
- the cache that will back the two-way lookupsentityLookup
- the instance that is able to find and persist entitiespublic EntityLookupCache(org.alfresco.repo.cache.SimpleCache cache, java.lang.String cacheRegion, EntityLookupCache.EntityLookupCallbackDAO entityLookup)
All keys will be unique to the given cache region, allowing the cache to be shared between instances of this class.
cache
- the cache that will back the two-way lookups; null to have no backing
in a cache.cacheRegion
- the region within the cache to use.entityLookup
- the instance that is able to find and persist entitiesMethod Detail |
---|
public org.alfresco.util.Pair getByKey(java.io.Serializable key)
entity callback
will be used if necessary.
It is up to the client code to decide if a null return value indicates a concurrency violation
or not; the former would normally result in a concurrency-related exception such as
ConcurrencyFailureException
.
key
- The entity key, which may be valid or invalid (null not allowed)
public org.alfresco.util.Pair getByValue(java.lang.Object value)
entity callback
will be used if no entry exists in the cache.
It is up to the client code to decide if a null return value indicates a concurrency violation
or not; the former would normally result in a concurrency-related exception such as
ConcurrencyFailureException
.
value
- The entity value, which may be valid or invalid (null is allowed)
public org.alfresco.util.Pair getOrCreateByValue(java.lang.Object value)
EntityLookupCache.EntityLookupCallbackDAO.findByValue(Object)
and EntityLookupCache.EntityLookupCallbackDAO.createValue(Object)
will be used if necessary.
value
- The entity value (null is allowed)
public int updateValue(java.io.Serializable key, java.lang.Object value)
EntityLookupCache.EntityLookupCallbackDAO.updateValue(Serializable, Object)
callback
will be used if necessary.
It is up to the client code to decide if a 0 return value indicates a concurrency violation
or not; usually the former will generate ConcurrencyFailureException
or something recognised
by the RetryingTransactionHelper
.
key
- The entity key, which may be valid or invalid (null not allowed)value
- The new entity value (may be null)
public java.io.Serializable getKey(java.io.Serializable valueKey)
value
- The entity value key, which must be valid (null not allowed)
public java.lang.Object getValue(java.io.Serializable key)
key
- The entity key, which may be valid or invalid (null not allowed)
public void setValue(java.io.Serializable key, java.lang.Object value)
key
- The entity key, which may be valid or invalid (null not allowed)value
- The new entity value (may be null)public int deleteByKey(java.io.Serializable key)
EntityLookupCache.EntityLookupCallbackDAO.deleteByKey(Serializable)
callback will be used if necessary.
It is up to the client code to decide if a 0 return value indicates a concurrency violation
or not; usually the former will generate ConcurrencyFailureException
or something recognised
by the RetryingTransactionHelper
.
key
- the entity key, which may be valid or invalid (null not allowed)
public int deleteByValue(java.lang.Object value)
EntityLookupCache.EntityLookupCallbackDAO.deleteByValue(Object)
callback will be used if necessary.
It is up to the client code to decide if a 0 return value indicates a concurrency violation
or not; usually the former will generate ConcurrencyFailureException
or something recognised
by the RetryingTransactionHelper
.
key
- the entity value, which may be valid or invalid (null allowed)
public void removeByKey(java.io.Serializable key)
public void removeByValue(java.lang.Object value)
value
- The entity value (null is allowed)public void clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |