public final class DefaultSimpleCache<K extends Serializable,V> extends Object implements org.alfresco.repo.cache.SimpleCache<K,V>, org.springframework.beans.factory.BeanNameAware
SimpleCache implementation backed by a Google Cache implementation.| Constructor and Description |
|---|
DefaultSimpleCache()
Default constructor.
|
DefaultSimpleCache(int maxItems,
boolean useMaxItems,
int ttlSecs,
int maxIdleSecs,
String cacheName)
Construct a cache using the specified capacity and name.
|
DefaultSimpleCache(int maxItems,
String cacheName)
Create a size limited, named cache with no other features enabled.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
contains(K key) |
V |
get(K key) |
String |
getCacheName()
Retrieve the name of this cache.
|
Collection<K> |
getKeys() |
int |
getMaxIdleSecs()
Get the time-to-idle setting in seconds.
|
int |
getMaxItems()
Gets the maximum number of items that the cache will hold.
|
int |
getTTLSecs()
Get the time-to-live setting in seconds.
|
boolean |
isUseMaxItems()
Is a size-cap in use?
|
void |
put(K key,
V value) |
boolean |
putAndCheckUpdate(K key,
V value)
put method that may be used to check for updates in a thread-safe manner. |
void |
remove(K key) |
void |
setBeanName(String cacheName)
Since there are many cache instances, it is useful to be able to associate
a name with each one.
|
void |
setCacheName(String cacheName)
Since there are many cache instances, it is useful to be able to associate
a name with each one.
|
String |
toString() |
public DefaultSimpleCache(int maxItems,
boolean useMaxItems,
int ttlSecs,
int maxIdleSecs,
String cacheName)
maxItems - The cache capacity. 0 = use DEFAULT_CAPACITYuseMaxItems - Whether the maxItems value should be applied as a size-cap for the cache.cacheName - An arbitrary cache name.public DefaultSimpleCache(int maxItems,
String cacheName)
maxItems - intcacheName - Stringpublic DefaultSimpleCache()
public boolean contains(K key)
contains in interface org.alfresco.repo.cache.SimpleCache<K extends Serializable,V>public Collection<K> getKeys()
getKeys in interface org.alfresco.repo.cache.SimpleCache<K extends Serializable,V>public V get(K key)
get in interface org.alfresco.repo.cache.SimpleCache<K extends Serializable,V>public void put(K key, V value)
put in interface org.alfresco.repo.cache.SimpleCache<K extends Serializable,V>public boolean putAndCheckUpdate(K key, V value)
put method that may be used to check for updates in a thread-safe manner.true if the put resulted in a change in value, false otherwise.public void remove(K key)
remove in interface org.alfresco.repo.cache.SimpleCache<K extends Serializable,V>public void clear()
clear in interface org.alfresco.repo.cache.SimpleCache<K extends Serializable,V>public int getMaxItems()
public boolean isUseMaxItems()
public int getTTLSecs()
public int getMaxIdleSecs()
public String getCacheName()
setCacheName(String)public void setCacheName(String cacheName)
cacheName - StringsetBeanName(String)public void setBeanName(String cacheName)
setBeanName in interface org.springframework.beans.factory.BeanNameAwarecacheName - Set automatically by Spring, but can be set manually if required.Copyright © 2005–2018 Alfresco Software. All rights reserved.