Cache
drift.Backbone.Cache: a key/value store of strings with an optional TTL.
Signatures
Get(key string) ([]byte, error) // RAW bytes, decode yourself
Set(key string, value any, ttlSeconds int) error // ttl 0 = never expires
Del(key string) error // named `delete` in the other five SDKsThree ways it differs by language
- Deletion is
Delin Go anddeletein the other five: a different identifier, not a re-spelling. - Ruby's
Cache.settakes its TTL as a required keyword argument:Drift::Backbone::Cache.set(key, value, ttl: 3600). The others take it positionally. - Rust's
cache::getreturnsOption<Value>, wrapping the raw value; unwrap it before returning it as a payload.
A JSON string stores its decoded contents, so Cache.Set("greeting", "hi\nthere", 60) stores the nine bytes of hi, a newline, and there, not the literal escape sequence. Anything else you pass (a number, a bool, a map, a struct) stores its JSON text instead, and Get hands that text back for you to parse. Only a value that is genuinely empty, an empty body, an empty string, or null, is refused, alongside an empty key, both with 400 key and value required.
A miss is not an error locally, and it is on a deployed slice.
Get on a name nothing set returns an empty result under drift atomic run. On a deployed slice the same call answers 404, which Go, Python, Node.js, Ruby and PHP all surface as an error rather than an empty value. Branch on the error deployed, not on an empty return, if the two need to be told apart.Cache is for speed, not durability.
It is capped independently of your tier: 1 MiB per value, 10,000 entries, 64 MiB of total value bytes. Past any of them
Set answers 429 rather than evicting anything older to make room. Treat it as data you can always recompute. The Backbone guide has the eviction behaviour.