MultiKeyCommands.scan

Iterates the set of keys in the currently selected Redis database. <p> Since this command allows for incremental iteration, returning only a small number of elements per call, it can be used in production without the downside of commands like {@link #keys(string)} or {@link RedisCommands#smembers(string)} )} that may block the server for a long time (even several seconds) when called against big collections of keys or elements. <p> SCAN basic usage!(br) SCAN is a cursor based iterator. This means that at every call of the command, the server returns an updated cursor that the user needs to use as the cursor argument in the next call. An iteration starts when the cursor is set to 0, and terminates when the cursor returned by the server is 0. <p> Scan guarantees!(br) The SCAN command, and the other commands in the SCAN family, are able to provide to the user a set of guarantees associated to full iterations. <ul> <li>A full iteration always retrieves all the elements that were present in the collection from the start to the end of a full iteration. This means that if a given element is inside the collection when an iteration is started, and is still there when an iteration terminates, then at some point SCAN returned it to the user. <li>A full iteration never returns any element that was NOT present in the collection from the start to the end of a full iteration. So if an element was removed before the start of an iteration, and is never added back to the collection for all the time an iteration lasts, SCAN ensures that this element will never be returned. </ul> However because SCAN has very little state associated (just the cursor) it has the following drawbacks: <ul> <li>A given element may be returned multiple times. It is up to the application to handle the case of duplicated elements, for example only using the returned elements in order to perform operations that are safe when re-applied multiple times. <li>Elements that were not constantly present in the collection during a full iteration, may be returned or not: it is undefined. </ul> <p> Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the DB.

@param cursor The cursor. @param params the scan parameters. For example a glob-style match pattern @return the scan result with the results of this iteration and the new position of the cursor @see <a href="https://redis.io/commands/scan">Redis SCAN documentation</a>

  1. ScanResult!(string) scan(string cursor)
  2. ScanResult!(string) scan(string cursor, ScanParams params)
    interface MultiKeyCommands
    ScanResult!(string)
    scan

Meta