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
ConstructorDescriptionScanCursor
(long cursorId) Crates newScanCursor
withScanOptions.NONE
ScanCursor
(long cursorId, ScanOptions options) Crates newScanCursor
ScanCursor
(ScanOptions options) Crates newScanCursor
withid=0
. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
protected void
doClose()
Customization hook for cleaning up resources on when callingclose()
.protected void
doOpen
(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.long
Get the reference cursor.long
boolean
hasNext()
boolean
isClosed()
protected boolean
isFinished
(long cursorId) Check whethercursorId
is finished.protected final boolean
isOpen()
protected final boolean
isReady()
protected T
Fetch the next item from the underlyingIterable
.next()
final ScanCursor<T>
open()
Initialize theCursor
prior to usage.void
remove()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.util.CloseableIterator
spliterator, stream
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
ScanCursor
public ScanCursor() -
ScanCursor
Crates newScanCursor
withid=0
.- Parameters:
options
- the scan options to apply.
-
ScanCursor
public ScanCursor(long cursorId) Crates newScanCursor
withScanOptions.NONE
- Parameters:
cursorId
- the cursor Id.
-
ScanCursor
Crates newScanCursor
- Parameters:
cursorId
- the cursor Id.options
- Defaulted toScanOptions.NONE
if null.
-
-
Method Details
-
doScan
Performs the actual scan command using the native client implementation. The given options are never null.- Parameters:
cursorId
-options
-- Returns:
-
open
Initialize theCursor
prior to usage. -
doOpen
protected void doOpen(long cursorId) Customization hook when callingopen()
.- Parameters:
cursorId
-
-
isFinished
protected boolean isFinished(long cursorId) Check whethercursorId
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 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in 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:
getPosition
in interfaceCursor<T>
- Returns:
- the current position of the cursor.
-