Interface ClusterScanCursor
-
- All Known Subinterfaces:
CommandManager.ClusterScanCursorDetail
public interface ClusterScanCursorA cursor is used to iterate through data returned by cluster SCAN requests.This interface is used in two ways:
- An
initialCursor()is passed toGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)to start a cluster SCAN request. - The result of the
GenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)call returns a cursor at index0of the returnedObject[]. This cursor can be supplied again to a call toGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor), provided thatisFinished()returnsfalse.
Note that cursors returned by
GenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)may hold external resources. These resources can be released by callingreleaseCursorHandle(). However, doing so will invalidate the cursor from being used in anotherGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor).To do this safely, follow this procedure:
- Call
GenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)with the cursor. - Call
releaseCursorHandle()to destroy the cursor. - Assign the new cursor returned by
GenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor).
- See Also:
GenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)- Example:
ClusterScanCursor cursor = ClusterScanCursor.initialCursor(); Object[] result; while (!cursor.isFinished()) { result = client.scan(cursor).get(); cursor.releaseCursorHandle(); cursor = (ClusterScanCursor) result[0]; Object[] stringResults = (Object[]) result[1]; System.out.println("\nSCAN iteration:"); Arrays.asList(stringResults).stream().forEach(i -> System.out.print(i + ", ")); }
-
-
Field Summary
Fields Modifier and Type Field Description static ClusterScanCursorINITIAL_CURSOR_INSTANCEThe special cursor used to start the first in a series ofGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)calls.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description static ClusterScanCursorinitalCursor()Deprecated.UseinitialCursor()instead.static ClusterScanCursorinitialCursor()Creates an empty cursor to be used in the initialGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)call.booleanisFinished()Indicates if this cursor is the last set of data available.voidreleaseCursorHandle()Releases resources related to this cursor.
-
-
-
Field Detail
-
INITIAL_CURSOR_INSTANCE
static final ClusterScanCursor INITIAL_CURSOR_INSTANCE
The special cursor used to start the first in a series ofGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)calls.
-
-
Method Detail
-
isFinished
boolean isFinished()
Indicates if this cursor is the last set of data available.If this method returns false, this cursor instance should get passed to
GenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)to get next set of data.- Returns:
- true if this cursor is the last set of data. False if there is potentially more data available.
-
releaseCursorHandle
void releaseCursorHandle()
Releases resources related to this cursor.This method can be called to immediately release resources tied to this cursor instance. Note that if this is called, this cursor cannot be used in
GenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor). Also, this method is optional for the caller. If it does not get called, cursor resources will be freed during garbage collection.
-
initialCursor
static ClusterScanCursor initialCursor()
Creates an empty cursor to be used in the initialGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)call.
-
initalCursor
@Deprecated static ClusterScanCursor initalCursor()
Deprecated.UseinitialCursor()instead.Creates an empty cursor to be used in the initialGenericClusterCommands.scan(glide.api.models.commands.scan.ClusterScanCursor)call.
-
-