public interface DataContainer<K,V> extends Iterable<InternalCacheEntry<K,V>>
Modifier and Type | Interface and Description |
---|---|
static interface |
DataContainer.ComputeAction<K,V> |
Modifier and Type | Method and Description |
---|---|
default long |
capacity()
Returns the capacity of the underlying container.
|
void |
clear()
Removes all entries in the container
|
InternalCacheEntry<K,V> |
compute(K key,
DataContainer.ComputeAction<K,V> action)
Computes the new value for the key.
|
boolean |
containsKey(Object k)
Tests whether an entry exists in the container
|
Set<InternalCacheEntry<K,V>> |
entrySet()
Returns a mutable set of immutable cache entries exposed as immutable Map.Entry instances.
|
void |
evict(K key)
Atomically, it removes the key from
DataContainer and passivates it to persistence. |
void |
executeTask(KeyFilter<? super K> filter,
BiConsumer<? super K,InternalCacheEntry<K,V>> action)
Executes task specified by the given action on the container key/values filtered using the specified key filter.
|
void |
executeTask(KeyValueFilter<? super K,? super V> filter,
BiConsumer<? super K,InternalCacheEntry<K,V>> action)
Executes task specified by the given action on the container key/values filtered using the specified keyvalue filter.
|
InternalCacheEntry<K,V> |
get(Object k)
Retrieves a cached entry
|
Iterator<InternalCacheEntry<K,V>> |
iterator() |
Iterator<InternalCacheEntry<K,V>> |
iteratorIncludingExpired()
Same as
iterator() except that is also returns expired entries. |
Set<K> |
keySet()
Returns a set of keys in the container.
|
InternalCacheEntry<K,V> |
peek(Object k)
Retrieves a cache entry in the same way as
get(Object) } except that it does not update or reorder any of
the internal constructs. |
void |
purgeExpired()
Deprecated.
This method doesn't allow for proper expiration notifications when a cache loader is also in use.
|
void |
put(K k,
V v,
Metadata metadata)
Puts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version
information...etc.
|
InternalCacheEntry<K,V> |
remove(Object k)
Removes an entry from the cache
The
key must be activate by invoking ActivationManager.onRemove(Object,
boolean) . |
default void |
resize(long newSize)
Resizes the capacity of the underlying container.
|
int |
size() |
int |
sizeIncludingExpired() |
Collection<V> |
values() |
forEach, spliterator
InternalCacheEntry<K,V> get(Object k)
k
- key under which entry is storedInternalCacheEntry<K,V> peek(Object k)
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 get(Object)
} when called while iterating through the data container
using methods like keySet()
to avoid changing the underlying collection's order.k
- key under which entry is storedvoid put(K k, V v, Metadata metadata)
key
must be activate by invoking ActivationManager.onUpdate(Object,
boolean)
.k
- key under which to store entryv
- value to storemetadata
- metadata of the entryboolean containsKey(Object k)
k
- key to testInternalCacheEntry<K,V> remove(Object k)
key
must be activate by invoking ActivationManager.onRemove(Object,
boolean)
.k
- key to removeint size()
int sizeIncludingExpired()
void clear()
Set<K> keySet()
get(Object)
method but instead peek(Object)
, in order to avoid changing the order of
the underlying collection as a side of effect of iterating through it.Collection<V> values()
Set<InternalCacheEntry<K,V>> entrySet()
@Deprecated void purgeExpired()
ExpirationManager.processExpiration()
ExpirationManager.processExpiration()
void evict(K key)
DataContainer
and passivates it to persistence.
The passivation must be done by invoking the method PassivationManager.passivate(org.infinispan.container.entries.InternalCacheEntry)
.key
- The key to evict.InternalCacheEntry<K,V> compute(K key, DataContainer.ComputeAction<K,V> action)
DataContainer.ComputeAction.compute(Object,
org.infinispan.container.entries.InternalCacheEntry, InternalEntryFactory)
.
The key
must be activate by invoking ActivationManager.onRemove(Object,
boolean)
or ActivationManager.onUpdate(Object, boolean)
depending if the value
returned by the DataContainer.ComputeAction
is null or not respectively.
Note the entry provided to DataContainer.ComputeAction
may be expired as these
entries are not filtered as many other methods do.
key
- The key.action
- The action that will compute the new value.InternalCacheEntry
associated to the key.void executeTask(KeyFilter<? super K> filter, BiConsumer<? super K,InternalCacheEntry<K,V>> action) throws InterruptedException
filter
- the filter for the container keysaction
- the specified action to execute on filtered key/valuesInterruptedException
void executeTask(KeyValueFilter<? super K,? super V> filter, BiConsumer<? super K,InternalCacheEntry<K,V>> action) throws InterruptedException
filter
- the filter for the container key/valuesaction
- the specified action to execute on filtered key/valuesInterruptedException
Iterator<InternalCacheEntry<K,V>> iterator()
This iterator only returns entries that are not expired, however it will not remove them while doing so.
iterator
in interface Iterable<InternalCacheEntry<K,V>>
Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()
iterator()
except that is also returns expired entries.default void resize(long newSize)
UnsupportedOperationException
is thrown otherwise.newSize
- the new sizedefault long capacity()
UnsupportedOperationException
is thrown
otherwise.Copyright © 2023 JBoss, a division of Red Hat. All rights reserved.