Interface InternalDataContainer<K,​V>

    • Method Detail

      • get

        @Deprecated
        InternalCacheEntry<K,​V> get​(Object k)
        Deprecated.
        since 10.1
        Retrieves a cached entry

        We should only ever be using the non blocking variant peek(int, Object) in Infinispan

        Specified by:
        get in interface DataContainer<K,​V>
        Parameters:
        k - key under which entry is stored
        Returns:
        entry, if it exists and has not expired, or null if not
      • get

        @Deprecated
        InternalCacheEntry<K,​V> get​(int segment,
                                          Object k)
        Deprecated.
        since 10.1
        Same as DataContainer.get(Object) except that the segment of the key can provided to lookup entries without calculating the segment for the given key
        Parameters:
        segment - segment for the key
        k - key under which entry is stored
        Returns:
        entry, if it exists and has not expired, or null if not
      • peek

        InternalCacheEntry<K,​V> peek​(int segment,
                                           Object k)
        Same as DataContainer.peek(Object) except that the segment of the key can provided to lookup entries without calculating the segment for the given key
        Parameters:
        segment - segment for the key
        k - key under which entry is stored
        Returns:
        entry, if it exists, or null if not
      • touch

        boolean touch​(int segment,
                      Object k,
                      long currentTimeMillis)
        Touches an entry in the data container. This will update the last access time of the entry as well as count this as a access for eviction based recency.
        Parameters:
        segment - segment for the key
        k - key under which entry is stored
        currentTimeMillis - the current time in milliseconds to touch the entry with
        Returns:
        true if the entry timestamp was touched
      • put

        void put​(int segment,
                 K k,
                 V v,
                 Metadata metadata,
                 long createdTimestamp,
                 long lastUseTimestamp)
        Same as DataContainer.put(Object, Object, Metadata) except that the segment of the key can provided to write/lookup entries without calculating the segment for the given key.

        Note: The timestamps ignored if the entry already exists in the data container.

        Parameters:
        segment - segment for the key
        k - key under which to store entry
        v - value to store
        metadata - metadata of the entry
        createdTimestamp - creation timestamp, or -1 to use the current time
        lastUseTimestamp - last use timestamp, or -1 to use the current time
        Since:
        10.0
      • containsKey

        boolean containsKey​(int segment,
                            Object k)
        Same as DataContainer.containsKey(Object) except that the segment of the key can provided to lookup if the entry exists without calculating the segment for the given key.
        Parameters:
        segment - segment for the key
        k - key under which entry is stored
        Returns:
        true if entry exists and has not expired; false otherwise
      • remove

        InternalCacheEntry<K,​V> remove​(int segment,
                                             Object k)
        Same as DataContainer.remove(Object) except that the segment of the key can provided to remove the entry without calculating the segment for the given key.
        Parameters:
        segment - segment for the key
        k - key to remove
        Returns:
        entry removed, or null if it didn't exist or had expired
      • evict

        void evict​(int segment,
                   K key)
        Same as DataContainer.evict(Object) except that the segment of the key can provided to remove the entry without calculating the segment for the given key.
        Parameters:
        segment - segment for the key
        key - The key to evict.
      • size

        default int size​(org.infinispan.commons.util.IntSet segments)
        Returns how many entries are present in the data container that map to the given segments without counting entries that are currently expired.
        Parameters:
        segments - segments of entries to count
        Returns:
        count of the number of entries in the container excluding expired entries
      • sizeIncludingExpired

        default int sizeIncludingExpired​(org.infinispan.commons.util.IntSet segments)
        Returns how many entries are present in the data container that map to the given segments including any entries that may be expired
        Parameters:
        segments - segments of entries to count
        Returns:
        count of the number of entries in the container including expired entries
      • clear

        void clear​(org.infinispan.commons.util.IntSet segments)
        Removes entries from the container whose key maps to one of the provided segments
        Parameters:
        segments - segments of entries to remove
      • spliterator

        Spliterator<InternalCacheEntry<K,​V>> spliterator​(org.infinispan.commons.util.IntSet segments)
        Same as DataContainer.spliterator() except that only entries that map to the provided segments are returned via this spliterator. The spliterator will not return expired entries.
        Parameters:
        segments - segments of entries to return
        Returns:
        spliterator containing entries mapping to those segments that aren't expired
      • spliteratorIncludingExpired

        Spliterator<InternalCacheEntry<K,​V>> spliteratorIncludingExpired​(org.infinispan.commons.util.IntSet segments)
        Same as DataContainer.spliteratorIncludingExpired() except that only entries that map to the provided segments are returned via this spliterator. The spliterator will return expired entries as well.
        Parameters:
        segments - segments of entries to use
        Returns:
        spliterator containing entries mapping to those segments that could be expired
      • iterator

        Iterator<InternalCacheEntry<K,​V>> iterator​(org.infinispan.commons.util.IntSet segments)
        Same as DataContainer.iterator() except that only entries that map to the provided segments are returned via the iterator. The iterator will not return expired entries.
        Parameters:
        segments - segments of entries to use
        Returns:
        iterator that returns all entries mapped to the given segments
      • iteratorIncludingExpired

        Iterator<InternalCacheEntry<K,​V>> iteratorIncludingExpired​(org.infinispan.commons.util.IntSet segments)
        Same as DataContainer.iteratorIncludingExpired() except that only entries that map to the provided segments are returned via the iterator. The iterator can return expired entries.
        Parameters:
        segments - segments of entries to use
        Returns:
        iterator that returns all entries mapped to the given segments that could be expired
      • forEach

        default void forEach​(org.infinispan.commons.util.IntSet segments,
                             Consumer<? super InternalCacheEntry<K,​V>> action)
        Performs the given action for each element of the container that maps to the given set of segments until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.
        Parameters:
        action - The action to be performed for each element
        Throws:
        NullPointerException - if the specified action is null
      • addSegments

        void addSegments​(org.infinispan.commons.util.IntSet segments)
        Sets what segments this data container should be using. Already associated segments are unaffected by this and takes a union of existing and new segments.
        Parameters:
        segments - segments to associate with this container
      • removeSegments

        void removeSegments​(org.infinispan.commons.util.IntSet segments)
        Removes and un-associates the given segments. This will notify any listeners registered via addRemovalListener(Consumer) of entries that were removed due to no longer being associated with this container. There is no guarantee if the consumer is invoked once or multiple times for a given group of segments and could be in any order.

        When this method is invoked an implementation is free to remove any entries that don't map to segments currently associated with this container. Note that entries that were removed due to their segments never being associated with this container do not notify listeners registered via addRemovalListener(Consumer).

        Parameters:
        segments - segments that should no longer be associated with this container
      • addRemovalListener

        void addRemovalListener​(Consumer<Iterable<InternalCacheEntry<K,​V>>> listener)
        Adds a listener that is invoked whenever removeSegments(IntSet) is invoked providing a way for the listener to see what actual entries were removed from the container.
        Parameters:
        listener - listener that invoked of removed entries
      • removeRemovalListener

        void removeRemovalListener​(Object listener)
        Removes a previously registered listener via addRemovalListener(Consumer).
        Parameters:
        listener - the listener to remove