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>, so a miss isNonerather than an error, so unwrap it before returning it as a payload.
The value must be a string.
The SDKs accept any type, but the slice deserializes
value as a JSON string, so Cache.Set("hits", 42, 60) answers 400 key and value required, naming the wrong problem, since both were present. An empty string is rejected the same way. Serialize numbers, maps and structs before you call.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. Treat it as data you can always recompute. The Backbone guide has the eviction behaviour.