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 newScanCursor
with an initial cursor andScanOptions.NONE
ScanCursor
(long cursorId) Deprecated.ScanCursor
(long cursorId, ScanOptions options) Deprecated.since 3.3.0 - UseScanCursor(CursorId, ScanOptions)
instead.ScanCursor
(Cursor.CursorId cursorId) Crates newScanCursor
withScanOptions.NONE
ScanCursor
(Cursor.CursorId cursorId, ScanOptions options) Crates newScanCursor
ScanCursor
(ScanOptions options) Crates newScanCursor
with an initial cursor. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
protected void
doClose()
Customization hook for cleaning up resources on when callingclose()
.protected void
doOpen
(long cursorId) Deprecated, for removal: This API element is subject to removal in a future version.since 3.3.0, usedoOpen(CursorId)
instead.protected void
doOpen
(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.long
Get the reference cursor.getId()
Returns the reference cursor.long
boolean
hasNext()
boolean
isClosed()
protected boolean
isFinished
(long cursorId) Deprecated, for removal: This API element is subject to removal in a future version.protected boolean
isFinished
(Cursor.CursorId 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()Crates newScanCursor
with an initial cursor andScanOptions.NONE
-
ScanCursor
Crates newScanCursor
with an initial cursor.- Parameters:
options
- the scan options to apply.
-
ScanCursor
Deprecated.since 3.3.0 - UseScanCursor(CursorId)
instead.Crates newScanCursor
withScanOptions.NONE
- Parameters:
cursorId
- the cursor Id.
-
ScanCursor
Crates newScanCursor
withScanOptions.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.NONE
ifnull
.
-
ScanCursor
Crates newScanCursor
- Parameters:
cursorId
- the cursor Id.options
- Defaulted toScanOptions.NONE
ifnull
.- 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 nevernull
.- 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 theCursor
prior 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 whethercursorId
is finished.- Parameters:
cursorId
- the cursor Id- Returns:
- true if the cursor is considered finished, false otherwise.s
- Since:
- 2.1
-
isFinished
Check whethercursorId
is 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:Cursor
Returns the reference cursor. -
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.
-
ScanCursor(CursorId)
instead.