public interface DataContainer<K,V> extends Iterable<InternalCacheEntry<K,V>>
Cache
. If you wish to convert
entries to the stored format, you should use the provided DataConversion
such as
cache.getAdvancedCache().getKeyDataConversion().toStorage(key);when dealing with keys or the following when dealing with values
cache.getAdvancedCache().getValueDataConversion().toStorage(value);You can also convert from storage to the user provided type by using the
DataConversion.fromStorage(Object)
method on any value returned from the DataContainerModifier 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
|
default Set<InternalCacheEntry<K,V>> |
entrySet()
Deprecated.
Please use iterator method if bulk operations are required.
|
void |
evict(K key)
Atomically, it removes the key from
DataContainer and passivates it to persistence. |
default long |
evictionSize()
Returns how large the eviction size is currently.
|
default void |
executeTask(KeyFilter<? super K> filter,
BiConsumer<? super K,InternalCacheEntry<K,V>> action)
Deprecated.
since 9.3 Please use the
iterator() method and apply filtering manually |
default void |
executeTask(KeyValueFilter<? super K,? super V> filter,
BiConsumer<? super K,InternalCacheEntry<K,V>> action)
Deprecated.
since 9.3 Please use the
iterator() method and apply filtering manually |
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. |
default Set<K> |
keySet()
Deprecated.
Please use iterator method if bulk operations are required.
|
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 |
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.
|
default int |
size() |
int |
sizeIncludingExpired() |
default Spliterator<InternalCacheEntry<K,V>> |
spliterator() |
default Spliterator<InternalCacheEntry<K,V>> |
spliteratorIncludingExpired()
Same as
spliterator() except that is also returns expired entries. |
default Collection<V> |
values()
Deprecated.
Please use iterator method if bulk operations are required.
|
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 iterator()
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 removedefault int size()
int sizeIncludingExpired()
void clear()
@Deprecated default 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.
This set of keys will include expired entries. If you wish to only retrieve non expired keys please use the
iterator()
method and retrieve keys from there.
@Deprecated default Collection<V> values()
entrySet()
and pull values from there directly.@Deprecated default Set<InternalCacheEntry<K,V>> entrySet()
This set is a read only backed view of the entries underneath. This set will only show non expired entries when invoked. The size method of the set will count expired entries for the purpose of having a O(1) time cost compared to O(N) if it is to not count expired entries.
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.@Deprecated default void executeTask(KeyFilter<? super K> filter, BiConsumer<? super K,InternalCacheEntry<K,V>> action) throws InterruptedException
iterator()
method and apply filtering manuallyfilter
- the filter for the container keysaction
- the specified action to execute on filtered key/valuesInterruptedException
@Deprecated default void executeTask(KeyValueFilter<? super K,? super V> filter, BiConsumer<? super K,InternalCacheEntry<K,V>> action) throws InterruptedException
iterator()
method and apply filtering manuallyfilter
- 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>>
default Spliterator<InternalCacheEntry<K,V>> spliterator()
This spliterator only returns entries that are not expired, however it will not remove them while doing so.
spliterator
in interface Iterable<InternalCacheEntry<K,V>>
Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()
iterator()
except that is also returns expired entries.default Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired()
spliterator()
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.default long evictionSize()
UnsupportedOperationException
is thrown otherwise. This value will always be lower than the value returned
from capacity()
Copyright © 2020 JBoss, a division of Red Hat. All rights reserved.