v0.7.0

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


OperationMatches againstResult itemsOrdering
Keys(pattern)Top-level key nameskeyLexicographic
Find(op, value, limit)Entire raw valuekeyNewest first
Query(filter, limit)Fields of JSON documentskey: rawValueNewest first

All three hold the database read lock and skip expired entries and __torii:* keys.

KEYS


  1. KEYS *
  2. KEYS user:*
  3. 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.

中文