Class ScanStream


  • public abstract class ScanStream
    extends Object
    Scan command support exposed through Flux.

    ScanStream uses reactive command interfaces to scan over keys (SCAN), sets (SSCAN), sorted sets ( ZSCAN), and hashes (HSCAN).

    Use ScanArgs.limit(long) to set the batch size.

    Data structure scanning is progressive and stateful and demand-aware. It supports full iterations (until all received cursors are exhausted) and premature termination. Subsequent scan commands to fetch the cursor data get only issued if the subscriber signals demand.

    Since:
    5.1
    Author:
    Mark Paluch, Mikhael Sokolov
    • Method Detail

      • scan

        public static <K,​V> Flux<K> scan​(RedisKeyReactiveCommands<K,​V> commands)
        Sequentially iterate over keys in the keyspace. This method uses SCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        Returns:
        a new Flux.
      • scan

        public static <K,​V> Flux<K> scan​(RedisKeyReactiveCommands<K,​V> commands,
                                               ScanArgs scanArgs)
        Sequentially iterate over keys in the keyspace. This method uses SCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        scanArgs - the scan arguments, must not be null.
        Returns:
        a new Flux.
      • hscan

        public static <K,​V> Flux<KeyValue<K,​V>> hscan​(RedisHashReactiveCommands<K,​V> commands,
                                                                  K key)
        Sequentially iterate over entries in a hash identified by key. This method uses HSCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        key - the hash to scan.
        Returns:
        a new Flux.
      • hscan

        public static <K,​V> Flux<KeyValue<K,​V>> hscan​(RedisHashReactiveCommands<K,​V> commands,
                                                                  K key,
                                                                  ScanArgs scanArgs)
        Sequentially iterate over entries in a hash identified by key. This method uses HSCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        key - the hash to scan.
        scanArgs - the scan arguments, must not be null.
        Returns:
        a new Flux.
      • sscan

        public static <K,​V> Flux<V> sscan​(RedisSetReactiveCommands<K,​V> commands,
                                                K key)
        Sequentially iterate over elements in a set identified by key. This method uses SSCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        key - the set to scan.
        Returns:
        a new Flux.
      • sscan

        public static <K,​V> Flux<V> sscan​(RedisSetReactiveCommands<K,​V> commands,
                                                K key,
                                                ScanArgs scanArgs)
        Sequentially iterate over elements in a set identified by key. This method uses SSCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        key - the set to scan.
        scanArgs - the scan arguments, must not be null.
        Returns:
        a new Flux.
      • zscan

        public static <K,​V> Flux<ScoredValue<V>> zscan​(RedisSortedSetReactiveCommands<K,​V> commands,
                                                             K key)
        Sequentially iterate over elements in a set identified by key. This method uses SSCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        key - the sorted set to scan.
        Returns:
        a new Flux.
      • zscan

        public static <K,​V> Flux<ScoredValue<V>> zscan​(RedisSortedSetReactiveCommands<K,​V> commands,
                                                             K key,
                                                             ScanArgs scanArgs)
        Sequentially iterate over elements in a set identified by key. This method uses SSCAN to perform an iterative scan.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        commands - the commands interface, must not be null.
        key - the sorted set to scan.
        scanArgs - the scan arguments, must not be null.
        Returns:
        a new Flux.