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
Redis client agnostic
Note: Please note that the
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 Summary
ConstructorsConstructorDescriptionScanCursor(long cursorId) Crates newScanCursorwithScanOptions.NONEScanCursor(long cursorId, ScanOptions options) Crates newScanCursorScanCursor(ScanOptions options) Crates newScanCursorwithid=0. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()protected voiddoClose()Customization hook for cleaning up resources on when callingclose().protected voiddoOpen(long cursorId) Customization hook when callingopen().protected abstract ScanIteration<T>doScan(long cursorId, ScanOptions options) Performs the actual scan command using the native client implementation.longGet the reference cursor.longbooleanhasNext()booleanisClosed()protected booleanisFinished(long cursorId) Check whethercursorIdis finished.protected final booleanisOpen()protected final booleanisReady()protected TFetch the next item from the underlyingIterable.next()final ScanCursor<T>open()Initialize theCursorprior to usage.voidremove()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.util.CloseableIterator
spliterator, streamMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
ScanCursor
public ScanCursor() -
ScanCursor
Crates newScanCursorwithid=0.- Parameters:
options- the scan options to apply.
-
ScanCursor
public ScanCursor(long cursorId) Crates newScanCursorwithScanOptions.NONE- Parameters:
cursorId- the cursor Id.
-
ScanCursor
Crates newScanCursor- Parameters:
cursorId- the cursor Id.options- Defaulted toScanOptions.NONEifnull.
-
-
Method Details
-
doScan
Performs the actual scan command using the native client implementation. The given options are nevernull.- Parameters:
cursorId-options-- Returns:
-
open
Initialize theCursorprior to usage. -
doOpen
protected void doOpen(long cursorId) Customization hook when callingopen().- Parameters:
cursorId-
-
isFinished
protected boolean isFinished(long cursorId) Check whethercursorIdis 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:CursorGet the reference cursor.
NOTE: the id might change while iterating items.- Specified by:
getCursorIdin interfaceCursor<T>- Returns:
-
hasNext
public boolean hasNext() -
next
-
moveNext
Fetch the next item from the underlyingIterable.- Parameters:
source-- Returns:
-
remove
public void remove() -
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableIterator<T>
-
doClose
protected void doClose()Customization hook for cleaning up resources on when callingclose(). -
isClosed
public boolean isClosed() -
isReady
protected final boolean isReady() -
isOpen
protected final boolean isOpen() -
getPosition
public long getPosition()- Specified by:
getPositionin interfaceCursor<T>- Returns:
- the current position of the cursor.
-