Interface RSetCache<V>

  • Type Parameters:
    V - value
    All Superinterfaces:
    <V>, <V>, <V>
    All Known Implementing Classes:
    RedissonSetCache, RedissonTransactionalSetCache

    public interface RSetCache<V>
    extends <V>, RExpirable, RSetCacheAsync<V>, RDestroyable

    Set-based cache with ability to set TTL for each object.

    Current Redis implementation doesn't have set entry eviction functionality. Thus values are checked for TTL expiration during any value read operation. If entry expired then it doesn't returns and clean task runs asynchronous. Clean task deletes removes 100 expired entries at once. In addition there is EvictionScheduler. This scheduler deletes expired entries in time interval between 5 seconds to 2 hours.

    If eviction is not required then it's better to use RSet.

    Author:
    Nikita Koksharov
    • Method Detail

      • getCountDownLatch

        RCountDownLatch getCountDownLatch​(V value)
        Returns RCountDownLatch instance associated with value
        Parameters:
        value - - set value
        Returns:
        RCountDownLatch object
      • getPermitExpirableSemaphore

        RPermitExpirableSemaphore getPermitExpirableSemaphore​(V value)
        Returns RPermitExpirableSemaphore instance associated with value
        Parameters:
        value - - set value
        Returns:
        RPermitExpirableSemaphore object
      • getSemaphore

        RSemaphore getSemaphore​(V value)
        Returns RSemaphore instance associated with value
        Parameters:
        value - - set value
        Returns:
        RSemaphore object
      • getFairLock

        RLock getFairLock​(V value)
        Returns RLock instance associated with value
        Parameters:
        value - - set value
        Returns:
        RLock object
      • getReadWriteLock

        RReadWriteLock getReadWriteLock​(V value)
        Returns RReadWriteLock instance associated with value
        Parameters:
        value - - set value
        Returns:
        RReadWriteLock object
      • getLock

        RLock getLock​(V value)
        Returns lock instance associated with value
        Parameters:
        value - - set value
        Returns:
        RLock object
      • stream

        <V> stream​(int count)
        Returns stream of elements in this set. Elements are loaded in batch. Batch size is defined by count param.
        Parameters:
        count - - size of elements batch
        Returns:
        stream of elements
      • stream

        < pattern,
                         int count)
        Returns stream of elements in this set. Elements are loaded in batch. Batch size is defined by count param. If pattern is not null then only elements match this pattern are loaded.
        Parameters:
        pattern - - search pattern
        count - - size of elements batch
        Returns:
        stream of elements
      • stream

        < pattern)
        Returns stream of elements in this set matches pattern.
        Parameters:
        pattern - - search pattern
        Returns:
        stream of elements
      • iterator

        <V> iterator​(int count)
        Returns an iterator over elements in this set. Elements are loaded in batch. Batch size is defined by count param.
        Parameters:
        count - - size of elements batch
        Returns:
        iterator
      • iterator

        < pattern,
                             int count)
        Returns an iterator over elements in this set. Elements are loaded in batch. Batch size is defined by count param. If pattern is not null then only elements match this pattern are loaded.
        Parameters:
        pattern - - search pattern
        count - - size of elements batch
        Returns:
        iterator
      • iterator

        < pattern)
        Returns values iterator matches pattern.
        Parameters:
        pattern - - search pattern
        Returns:
        iterator
      • mapReduce

        <KOut,​VOut> RCollectionMapReduce<V,​KOut,​VOut> mapReduce()
        Returns RMapReduce object associated with this map
        Type Parameters:
        KOut - output key
        VOut - output value
        Returns:
        MapReduce instance
      • add

        boolean add​(V value,
                    long ttl,
                     unit)
        Stores value with specified time to live. Value expires after specified time to live.
        Parameters:
        value - to add
        ttl - - time to live for key\value entry. If 0 then stores infinitely.
        unit - - time unit
        Returns:
        true if value has been added. false if value already been in collection.
      • size

        int size()
        Returns the number of elements in cache. This number can reflects expired elements too due to non realtime cleanup process.
        Specified by:
         in interface <V>
        Specified by:
         in interface <V>
        Returns:
        size of set
      • readAll

        <V> readAll()
        Read all elements at once
        Returns:
        values
      • tryAdd

        boolean tryAdd​(V... values)
        Tries to add elements only if none of them in set.
        Parameters:
        values - - values to add
        Returns:
        true if elements successfully added, otherwise false.
      • tryAdd

        boolean tryAdd​(long ttl,
                        unit,
                       V... values)
        Tries to add elements only if none of them in set.
        Parameters:
        values - - values to add
        ttl - - time to live for value. If 0 then stores infinitely.
        unit - - time unit
        Returns:
        true if elements successfully added, otherwise false.