public class EntityLookupCache
extends java.lang.Object
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:
| Modifier and Type | Class and Description |
|---|---|
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 and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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 entitiespublic 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()
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.