Skip to content

BUCKET.CLOSE

Closes a cursor and releases its associated query context from the session.

BUCKET.CLOSE <operation> <cursor-id>
ParameterTypeRequiredDescription
operationstringYesThe operation type. Must be QUERY, DELETE, or UPDATE.
cursor-idintegerYesThe cursor ID returned by the initial command (BUCKET.QUERY, BUCKET.DELETE, or BUCKET.UPDATE).

Returns OK on success.

Argument errors:

Error CodeError messageCause
ERRUnknown '<operation>' operationThe operation type is not QUERY, DELETE, or UPDATE.

Bucket errors:

Error CodeError messageCause
ERRno cursor found-

Close a query cursor:

> BUCKET.QUERY users '{}' BATCH 100
cursor_id -> (integer) 1
entries -> [...] (first 100 documents)
> BUCKET.CLOSE QUERY 1
OK

Double-close returns an error:

> BUCKET.QUERY users '{}' BATCH 100
cursor_id -> (integer) 1
entries -> [...]
> BUCKET.CLOSE QUERY 1
OK
> BUCKET.CLOSE QUERY 1
(error) ERR no cursor found

Close after pagination:

> BUCKET.DELETE users '{"status": "inactive"}' BATCH 50
cursor_id -> (integer) 1
object_ids -> [...] (first 50 deleted)
> BUCKET.ADVANCE DELETE 1
cursor_id -> (integer) 1
object_ids -> [...] (next 50 deleted)
> BUCKET.CLOSE DELETE 1
OK

Closing one cursor does not affect others:

> BUCKET.QUERY users '{}' BATCH 10
cursor_id -> (integer) 1
entries -> [...]
> BUCKET.DELETE users '{"status": "inactive"}' BATCH 10
cursor_id -> (integer) 2
object_ids -> [...]
> BUCKET.CLOSE QUERY 1
OK
> BUCKET.ADVANCE DELETE 2
cursor_id -> (integer) 2
object_ids -> [...] (still works)