Querying
Last updated
This page compares ToriiDB's three scan operations and covers key globbing with KEYS and how results are limited and ordered.
Scan Operations
| Operation | Matches against | Result items | Ordering |
|---|---|---|---|
Keys(pattern) |
Top-level key names | key | Lexicographic |
Find(op, value, limit) |
Entire raw value | key | Newest first |
Query(filter, limit) |
Fields of JSON documents | key: rawValue |
Newest first |
All three hold the database read lock and skip expired entries and __torii:* keys.
KEYS
KEYS *
KEYS user:*
KEYS cache:?
Patterns use Go path.Match (*, ?, [...]). An invalid pattern matches nothing. Dot notation is not interpreted.
The daemon's keys op adds paging and the entries op adds substring and time filters; see Socket Daemon.
Limits and Ordering
FIND and QUERY sort by UpdatedAt (or CreatedAt when unset) descending, then by result text. A trailing LIMIT <n> with n > 0 truncates after sorting; otherwise all matches are returned. More than 1024 keys are scanned in parallel blocks of 1024 and merged before sorting.