v0.7.0

SET, DEL, and INCR

Last updated


This page covers the ToriiDB commands that write, delete, and increment keys, including how trailing options are parsed.

SET


  1. SET <key> <value> [NX|XX] [seconds] [VECTOR]

Options are peeled from the end in this order, and each is only considered while at least two tokens remain:
  1. VECTOR (case-insensitive)
  2. a positive integer → expiry of now + seconds
  3. NX or XX

Because of this, SET version 2 3 stores "2" with a 3-second TTL, while SET n 5 stores 5.
FailureResponse
NX on an existing key, XX on a missing key, field write error(nil)
VECTOR with a dotted keyerror: VECTOR not supported on field-level SET
VECTOR error (no embedder, blank text)error: <message>

DEL


  1. DEL <key> [key2] ...

With one dotted argument, deletes that JSON field and returns OK or (nil). Otherwise deletes top-level keys and returns (integer) <removed>.

INCR


  1. INCR <key> [delta]

delta defaults to 1 and may be fractional; a non-number returns error: delta must be a number. The target must be an existing int/float key or numeric JSON field; anything else returns (nil).

中文