@ThreadSafe public class DefaultDataContainer extends Object implements DataContainer
Modifier and Type | Class and Description |
---|---|
static class |
DefaultDataContainer.EntryIterator |
DataContainer.ComputeAction
Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<Object,InternalCacheEntry> |
entries |
protected InternalEntryFactory |
entryFactory |
Modifier | Constructor and Description |
---|---|
|
DefaultDataContainer(int concurrencyLevel) |
protected |
DefaultDataContainer(int concurrencyLevel,
int maxEntries,
EvictionStrategy strategy,
EvictionThreadPolicy policy) |
Modifier and Type | Method and Description |
---|---|
static DataContainer |
boundedDataContainer(int concurrencyLevel,
int maxEntries,
EvictionStrategy strategy,
EvictionThreadPolicy policy) |
void |
clear()
Removes all entries in the container
|
void |
compute(Object key,
DataContainer.ComputeAction action)
Computes the new value for the key.
|
boolean |
containsKey(Object k)
Tests whether an entry exists in the container
|
Set<InternalCacheEntry> |
entrySet()
Returns a mutable set of immutable cache entries exposed as immutable Map.Entry instances.
|
void |
evict(Object k)
Atomically, it removes the key from
DataContainer and passivates it to persistence. |
InternalCacheEntry |
get(Object k)
Retrieves a cached entry
|
void |
initialize(EvictionManager evictionManager,
PassivationManager passivator,
InternalEntryFactory entryFactory,
ActivationManager activator,
CacheLoaderManager clm) |
Iterator<InternalCacheEntry> |
iterator() |
Set<Object> |
keySet()
Returns a set of keys in the container.
|
InternalCacheEntry |
peek(Object key)
Retrieves a cache entry in the same way as
DataContainer.get(Object) } except that it does not update or reorder any of
the internal constructs. |
void |
purgeExpired()
Purges entries that have passed their expiry time
|
void |
put(Object k,
Object v,
EntryVersion version,
long lifespan,
long maxIdle)
Puts an entry in the cache along with a lifespan and a maxIdle time
If the
key does not exists previously, it must be activate by invoking ActivationManager.activate(Object) . |
InternalCacheEntry |
remove(Object k)
Removes an entry from the cache
|
int |
size() |
static DataContainer |
unBoundedDataContainer(int concurrencyLevel) |
Collection<Object> |
values() |
protected final ConcurrentMap<Object,InternalCacheEntry> entries
protected InternalEntryFactory entryFactory
public DefaultDataContainer(int concurrencyLevel)
protected DefaultDataContainer(int concurrencyLevel, int maxEntries, EvictionStrategy strategy, EvictionThreadPolicy policy)
public void initialize(EvictionManager evictionManager, PassivationManager passivator, InternalEntryFactory entryFactory, ActivationManager activator, CacheLoaderManager clm)
public static DataContainer boundedDataContainer(int concurrencyLevel, int maxEntries, EvictionStrategy strategy, EvictionThreadPolicy policy)
public static DataContainer unBoundedDataContainer(int concurrencyLevel)
public InternalCacheEntry peek(Object key)
DataContainer
DataContainer.get(Object)
} except that it does not update or reorder any of
the internal constructs. I.e., expiration does not happen, and in the case of the LRU container, the entry is not
moved to the end of the chain.
This method should be used instead of DataContainer.get(Object)
} when called while iterating through the data container
using methods like DataContainer.keySet()
to avoid changing the underlying collection's order.peek
in interface DataContainer
key
- key under which entry is storedpublic InternalCacheEntry get(Object k)
DataContainer
get
in interface DataContainer
k
- key under which entry is storedpublic void put(Object k, Object v, EntryVersion version, long lifespan, long maxIdle)
DataContainer
key
does not exists previously, it must be activate by invoking ActivationManager.activate(Object)
.put
in interface DataContainer
k
- key under which to store entryv
- value to storelifespan
- lifespan in milliseconds. -1 means immortal.maxIdle
- max idle time for which to store entry. -1 means forever.public boolean containsKey(Object k)
DataContainer
containsKey
in interface DataContainer
k
- key to testpublic InternalCacheEntry remove(Object k)
DataContainer
remove
in interface DataContainer
k
- key to removepublic void evict(Object k)
DataContainer
DataContainer
and passivates it to persistence.
The passivation must be done by invoking the method PassivationManager.passivate(org.infinispan.container.entries.InternalCacheEntry)
.evict
in interface DataContainer
k
- The key to evict.public int size()
size
in interface DataContainer
public void clear()
DataContainer
clear
in interface DataContainer
public Set<Object> keySet()
DataContainer
DataContainer.get(Object)
method but instead DataContainer.peek(Object)
, in order to avoid changing the order of
the underlying collection as a side of effect of iterating through it.keySet
in interface DataContainer
public Collection<Object> values()
values
in interface DataContainer
public Set<InternalCacheEntry> entrySet()
DataContainer
entrySet
in interface DataContainer
public void purgeExpired()
DataContainer
purgeExpired
in interface DataContainer
public void compute(Object key, DataContainer.ComputeAction action)
DataContainer
DataContainer.ComputeAction.compute(Object, org.infinispan.container.entries.InternalCacheEntry, InternalEntryFactory)
.
If the key
does not exists previously, it must be activate by invoking ActivationManager.activate(Object)
.compute
in interface DataContainer
key
- The key.action
- The action that will compute the new value.public Iterator<InternalCacheEntry> iterator()
iterator
in interface Iterable<InternalCacheEntry>
Copyright © 2017 JBoss, a division of Red Hat. All Rights Reserved.