|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ehcache.core.Ehcache<K,V>
public class Ehcache<K,V>
Implementation of the Cache
interface when no CacheLoaderWriter
is involved.
Ehcache
users should not have to depend on this type but rely exclusively on the api types in package
org.ehcache
.
EhcacheWithLoaderWriter
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.ehcache.Cache |
---|
Cache.Entry<K,V> |
Field Summary | |
---|---|
protected org.slf4j.Logger |
logger
|
Constructor Summary | |
---|---|
Ehcache(CacheConfiguration<K,V> configuration,
Store<K,V> store,
CacheEventDispatcher<K,V> eventDispatcher,
org.slf4j.Logger logger)
Creates a new Ehcache based on the provided parameters. |
Method Summary | |
---|---|
void |
addHook(LifeCycled hook)
Add lifecycle hooks |
void |
clear()
Removes all mapping currently present in the Cache without invoking the CacheLoaderWriter or any
registered CacheEventListener instances
This is not an atomic operation and can potentially be very expensive |
void |
close()
Releases all data held in this UserManagedCache. |
boolean |
containsKey(K key)
Checks whether a mapping for the given key is present, without retrieving the associated value |
V |
get(K key)
Retrieve the value currently mapped to the provided key |
java.util.Map<K,V> |
getAll(java.util.Set<? extends K> keys)
Retrieves all values associated with the given keys. |
java.util.Map<BulkOps,org.terracotta.statistics.jsr166e.LongAdder> |
getBulkMethodEntries()
BulkMethodEntries |
CacheLoaderWriter<? super K,V> |
getCacheLoaderWriter()
CacheLoaderWriter |
Jsr107Cache<K,V> |
getJsr107Cache()
Jsr107Cache |
CacheRuntimeConfiguration<K,V> |
getRuntimeConfiguration()
Exposes the CacheRuntimeConfiguration associated with this Cache instance. |
Status |
getStatus()
Returns the current Status for this CacheManager |
void |
init()
Attempts at having this UserManagedCache go to Status.AVAILABLE . |
java.util.Iterator<Cache.Entry<K,V>> |
iterator()
|
void |
put(K key,
V value)
Associates the provided value to the given key |
void |
putAll(java.util.Map<? extends K,? extends V> entries)
Associates all the provided key:value pairs. |
V |
putIfAbsent(K key,
V value)
If the provided key is not associated with a value, then associate it with the provided value. |
void |
remove(K key)
Removes the value, if any, associated with the provided key |
boolean |
remove(K key,
V value)
If the provided key is associated with the provided value then remove the entry. |
void |
removeAll(java.util.Set<? extends K> keys)
Removes any associates for the given keys. |
V |
replace(K key,
V value)
If the provided key is associated with a value, then replace that value with the provided value. |
boolean |
replace(K key,
V oldValue,
V newValue)
If the provided key is associated with oldValue , then replace that value with newValue . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.slf4j.Logger logger
Constructor Detail |
---|
public Ehcache(CacheConfiguration<K,V> configuration, Store<K,V> store, CacheEventDispatcher<K,V> eventDispatcher, org.slf4j.Logger logger)
Ehcache
based on the provided parameters.
configuration
- the cache configurationstore
- the store to useeventDispatcher
- the event dispatcherlogger
- the loggerMethod Detail |
---|
public java.util.Map<BulkOps,org.terracotta.statistics.jsr166e.LongAdder> getBulkMethodEntries()
getBulkMethodEntries
in interface InternalCache<K,V>
public V get(K key)
get
in interface Cache<K,V>
key
- the key to query the value for
public void put(K key, V value)
put
in interface Cache<K,V>
key
- the key, may not be nullvalue
- the value, may not be nullpublic boolean containsKey(K key)
containsKey
in interface Cache<K,V>
key
- the key
public void remove(K key)
remove
in interface Cache<K,V>
key
- the key to remove the value forpublic void clear()
CacheLoaderWriter
or any
registered CacheEventListener
instances
This is not an atomic operation and can potentially be very expensive
clear
in interface Cache<K,V>
public java.util.Iterator<Cache.Entry<K,V>> iterator()
iterator
in interface java.lang.Iterable<Cache.Entry<K,V>>
public java.util.Map<K,V> getAll(java.util.Set<? extends K> keys) throws BulkCacheLoadingException
getAll
in interface Cache<K,V>
keys
- keys to query for
null
if the key was not mapped
BulkCacheLoadingException
- if loading some or all values failedpublic void putAll(java.util.Map<? extends K,? extends V> entries) throws BulkCacheWritingException
putAll
in interface Cache<K,V>
entries
- key:value pairs to associate
BulkCacheWritingException
- if the CacheLoaderWriter
associated with this cache threw an Exception
while writing given key:value pairs to underlying system of record.public void removeAll(java.util.Set<? extends K> keys) throws BulkCacheWritingException
removeAll
in interface Cache<K,V>
keys
- keys to remove values for
BulkCacheWritingException
- if the CacheLoaderWriter
associated with this cache threw an Exception
while removing mappings for given keys from underlying system of record.public V putIfAbsent(K key, V value)
putIfAbsent
in interface Cache<K,V>
key
- the key to be associated withvalue
- the value to associate
null
if nonepublic boolean remove(K key, V value)
remove
in interface Cache<K,V>
key
- the key to removevalue
- the value to check against
true
if the entry was removedpublic V replace(K key, V value)
replace
in interface Cache<K,V>
key
- the key to be associated withvalue
- the value to associate
null
if nonepublic boolean replace(K key, V oldValue, V newValue)
oldValue
, then replace that value with newValue
.
replace
in interface Cache<K,V>
key
- the key to be associated witholdValue
- the value to check againstnewValue
- the value to associate
true
if the value was replacedpublic CacheRuntimeConfiguration<K,V> getRuntimeConfiguration()
CacheRuntimeConfiguration
associated with this Cache instance.
getRuntimeConfiguration
in interface Cache<K,V>
public void init()
Status.AVAILABLE
.
Should this throw, while the UserManagedCache isn't yet Status.AVAILABLE
, it will try to go back
to Status.UNINITIALIZED
properly.
init
in interface UserManagedCache<K,V>
public void close()
Should this throw, while the UserManagedCache isn't yet Status.UNINITIALIZED
, it will keep on
trying to go to Status.UNINITIALIZED
properly.
close
in interface UserManagedCache<K,V>
public Status getStatus()
Status
for this CacheManager
getStatus
in interface UserManagedCache<K,V>
Status
public void addHook(LifeCycled hook)
addHook
in interface InternalCache<K,V>
hook
- hook it to lifecyclepublic Jsr107Cache<K,V> getJsr107Cache()
getJsr107Cache
in interface InternalCache<K,V>
public CacheLoaderWriter<? super K,V> getCacheLoaderWriter()
getCacheLoaderWriter
in interface InternalCache<K,V>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |