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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.redis.core.Cursor
Cursor.CursorId -
Constructor Summary
ConstructorsConstructorDescriptionCrates newScanCursorwith an initial cursor andScanOptions.NONEScanCursor(long cursorId) Deprecated.ScanCursor(long cursorId, ScanOptions options) Deprecated.since 3.3.0 - UseScanCursor(CursorId, ScanOptions)instead.ScanCursor(Cursor.CursorId cursorId) Crates newScanCursorwithScanOptions.NONEScanCursor(Cursor.CursorId cursorId, ScanOptions options) Crates newScanCursorScanCursor(ScanOptions options) Crates newScanCursorwith an initial cursor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()protected voiddoClose()Customization hook for cleaning up resources on when callingclose().protected voiddoOpen(long cursorId) Deprecated, for removal: This API element is subject to removal in a future version.since 3.3.0, usedoOpen(CursorId)instead.protected voiddoOpen(Cursor.CursorId cursorId) Customization hook when callingopen().protected ScanIteration<T>doScan(long cursorId, ScanOptions options) Deprecated.since 3.3.0, cursorId, can exceedLong.MAX_VALUE.protected ScanIteration<T>doScan(Cursor.CursorId cursorId, ScanOptions options) Performs the actual scan command using the native client implementation.longGet the reference cursor.getId()Returns the reference cursor.longbooleanhasNext()booleanisClosed()protected booleanisFinished(long cursorId) Deprecated, for removal: This API element is subject to removal in a future version.protected booleanisFinished(Cursor.CursorId 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()Crates newScanCursorwith an initial cursor andScanOptions.NONE -
ScanCursor
Crates newScanCursorwith an initial cursor.- Parameters:
options- the scan options to apply.
-
ScanCursor
Deprecated.since 3.3.0 - UseScanCursor(CursorId)instead.Crates newScanCursorwithScanOptions.NONE- Parameters:
cursorId- the cursor Id.
-
ScanCursor
Crates newScanCursorwithScanOptions.NONE- Parameters:
cursorId- the cursor Id.- Since:
- 3.3.0
-
ScanCursor
Deprecated.since 3.3.0 - UseScanCursor(CursorId, ScanOptions)instead.Crates newScanCursor- Parameters:
cursorId- the cursor Id.options- Defaulted toScanOptions.NONEif null.
-
ScanCursor
Crates newScanCursor- Parameters:
cursorId- the cursor Id.options- Defaulted toScanOptions.NONEifnull.- Since:
- 3.3.0
-
-
Method Details
-
doScan
Deprecated.since 3.3.0, cursorId, can exceedLong.MAX_VALUE.Performs the actual scan command using the native client implementation. The given options are never null.- Parameters:
cursorId-options-- Returns:
-
doScan
Performs the actual scan command using the native client implementation. The given options are nevernull.- Parameters:
cursorId-options-- Returns:
- Since:
- 3.3.0
-
open
Initialize theCursorprior to usage. -
doOpen
Deprecated, for removal: This API element is subject to removal in a future version.since 3.3.0, usedoOpen(CursorId)instead.Customization hook when callingopen().- Parameters:
cursorId-
-
doOpen
Customization hook when callingopen().- Parameters:
cursorId-
-
isFinished
Deprecated, for removal: This API element is subject to removal in a future version.Check whethercursorIdis finished.- Parameters:
cursorId- the cursor Id- Returns:
- true if the cursor is considered finished, false otherwise.s
- Since:
- 2.1
-
isFinished
Check whethercursorIdis finished.- Parameters:
cursorId- the cursor Id- Returns:
- true if the cursor is considered finished, false otherwise.s
- Since:
- 3.3.0
-
getId
Description copied from interface:CursorReturns the reference cursor. -
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.
-
ScanCursor(CursorId)instead.