Class ScanCursor<T>

java.lang.Object
org.springframework.data.redis.core.ScanCursor<T>
Type Parameters:
T -
All Implemented Interfaces:
Closeable, AutoCloseable, Iterator<T>, Cursor<T>, CloseableIterator<T>
Direct Known Subclasses:
KeyBoundCursor

public abstract class ScanCursor<T> extends Object implements Cursor<T>
Redis client agnostic Cursor implementation continuously loading additional results from Redis server until reaching its starting point zero.
Note: Please note that the ScanCursor has to be initialized (open() prior to usage. Any failures during scanning will close the cursor and release any associated resources such as connections.
Since:
1.4
Author:
Christoph Strobl, Thomas Darimont, Duobiao Ou, Marl Paluch
  • Constructor Details

  • Method Details

    • doScan

      protected abstract ScanIteration<T> doScan(long cursorId, ScanOptions options)
      Performs the actual scan command using the native client implementation. The given options are never null.
      Parameters:
      cursorId -
      options -
      Returns:
    • open

      public final ScanCursor<T> open()
      Initialize the Cursor prior to usage.
    • doOpen

      protected void doOpen(long cursorId)
      Customization hook when calling open().
      Parameters:
      cursorId -
    • isFinished

      protected boolean isFinished(long cursorId)
      Check whether cursorId is finished.
      Parameters:
      cursorId - the cursor Id
      Returns:
      true if the cursor is considered finished, false otherwise.s
      Since:
      2.1
    • getCursorId

      public long getCursorId()
      Description copied from interface: Cursor
      Get the reference cursor.
      NOTE: the id might change while iterating items.
      Specified by:
      getCursorId in interface Cursor<T>
      Returns:
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
    • next

      public T next()
      Specified by:
      next in interface Iterator<T>
    • moveNext

      protected T moveNext(Iterator<T> source)
      Fetch the next item from the underlying Iterable.
      Parameters:
      source -
      Returns:
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<T>
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface CloseableIterator<T>
    • doClose

      protected void doClose()
      Customization hook for cleaning up resources on when calling close().
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface Cursor<T>
      Returns:
      true if cursor closed.
    • isReady

      protected final boolean isReady()
    • isOpen

      protected final boolean isOpen()
    • getPosition

      public long getPosition()
      Specified by:
      getPosition in interface Cursor<T>
      Returns:
      the current position of the cursor.