Package org.infinispan.container
Interface DataContainer<K,V>
- All Superinterfaces:
Iterable<InternalCacheEntry<K,
V>>
- All Known Subinterfaces:
InternalDataContainer<K,
V>
- All Known Implementing Classes:
AbstractDelegatingInternalDataContainer
,AbstractInternalDataContainer
,BoundedOffHeapDataContainer
,BoundedSegmentedDataContainer
,DefaultDataContainer
,DefaultSegmentedDataContainer
,L1SegmentedDataContainer
,OffHeapDataContainer
,SegmentedBoundedOffHeapDataContainer
The main internal data structure which stores entries. Care should be taken when using this directly as entries
could be stored in a different way than they were given to a
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 DataContainer- Since:
- 4.0
- Author:
- Manik Surtani (manik@jboss.org), Galder ZamarreƱo, Vladimir Blagojevic
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault long
capacity()
Returns the capacity of the underlying container.void
clear()
Removes all entries in the containercompute
(K key, DataContainer.ComputeAction<K, V> action) Computes the new value for the key.boolean
Tests whether an entry exists in the containervoid
Atomically, it removes the key fromDataContainer
and passivates it to persistence.default long
Returns how large the eviction size is currently.Deprecated, for removal: This API element is subject to removal in a future version.iterator()
Same asiterator()
except that is also returns expired entries.Retrieves a cache entry in the same way asget(Object)
} except that it does not update or reorder any of the internal constructs.void
Puts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version information...etc.Removes an entry from the cachedefault void
resize
(long newSize) Resizes the capacity of the underlying container.default int
size()
int
default Spliterator<InternalCacheEntry<K,
V>> default Spliterator<InternalCacheEntry<K,
V>> Same asspliterator()
except that is also returns expired entries.
-
Method Details
-
get
Deprecated, for removal: This API element is subject to removal in a future version.since 10.1 - Please usepeek(Object)
instead.Retrieves a cached entry- Parameters:
k
- key under which entry is stored- Returns:
- entry, if it exists and has not expired, or null if not
-
peek
Retrieves a cache entry in the same way asget(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 ofget(Object)
} when called while iterating through the data container using methods likeiterator()
to avoid changing the underlying collection's order.- Parameters:
k
- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
put
Puts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version information...etc.- Parameters:
k
- key under which to store entryv
- value to storemetadata
- metadata of the entry
-
containsKey
Tests whether an entry exists in the container- Parameters:
k
- key to test- Returns:
- true if entry exists and has not expired; false otherwise
-
remove
Removes an entry from the cache- Parameters:
k
- key to remove- Returns:
- entry removed, or null if it didn't exist or had expired
-
size
default int size()- Returns:
- count of the number of entries in the container excluding expired entries
-
sizeIncludingExpired
int sizeIncludingExpired()- Returns:
- count of the number of entries in the container including expired entries
-
clear
void clear()Removes all entries in the container -
evict
Atomically, it removes the key fromDataContainer
and passivates it to persistence. The passivation must be done by invoking the methodPassivationManager.passivateAsync(InternalCacheEntry)
.- Parameters:
key
- The key to evict.
-
compute
Computes the new value for the key. SeeDataContainer.ComputeAction.compute(Object, org.infinispan.container.entries.InternalCacheEntry, InternalEntryFactory)
.Note the entry provided to
DataContainer.ComputeAction
may be expired as these entries are not filtered as many other methods do.- Parameters:
key
- The key.action
- The action that will compute the new value.- Returns:
- The
InternalCacheEntry
associated to the key.
-
iterator
Iterator<InternalCacheEntry<K,V>> iterator()This iterator only returns entries that are not expired, however it will not remove them while doing so.
-
spliterator
This spliterator only returns entries that are not expired, however it will not remove them while doing so.
- Specified by:
spliterator
in interfaceIterable<K>
- Returns:
- spliterator that doesn't produce expired entries
-
iteratorIncludingExpired
Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()Same asiterator()
except that is also returns expired entries.- Returns:
- iterator that returns all entries including expired ones
-
spliteratorIncludingExpired
Same asspliterator()
except that is also returns expired entries.- Returns:
- spliterator that returns all entries including expired ones
-
resize
default void resize(long newSize) Resizes the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise.- Parameters:
newSize
- the new size
-
capacity
default long capacity()Returns the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise.- Returns:
-
evictionSize
default long evictionSize()Returns how large the eviction size is currently. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise. This value will always be lower than the value returned fromcapacity()
- Returns:
- how large the counted eviction is
-
peek(Object)
instead.