drift Docs
Start
What is Drift?
The tour, if you are new here.
Use cases
Whether Drift does your thing.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, four unit prices, two rules.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Route gates, API keys and your account.
Security
Boundaries, sandboxing and hardening.
Troubleshooting
Error codes
What went wrong, and what to do about it.
Legal
Acceptable use
What a slice may not be used for.
Data processing
The DPA, and every sub-processor.

Backbone Cache

A key/value store with an optional TTL in seconds (0 = no expiry):

Go
drift.Backbone.Cache.Set("session:abc", token, 3600)
drift.Backbone.Cache.Set("hits", strconv.Itoa(42), 60)   // stored as a string either way; see below
v, _ := drift.Backbone.Cache.Get("session:abc")

The value always comes back as a string.

The SDKs accept any JSON-serializable type: a JSON string stores its own decoded bytes, and anything else, a number, a bool, an array, an object, stores its JSON text instead. Cache.Set("hits", 42, 60) stores the two characters 42, and Cache.Get("hits") reads them back as a string, not a number, so decode it yourself if you need the original type. Only a genuinely empty value, an empty string or a JSON null, is refused, with 400 key and value required naming key even when only the value was the problem.

Capacity

The cache is capped independently of your tier: 1 MiB per value, 10,000 entries, and 64 MiB of total value bytes. Crossing any of the three fails the set with 429 and a message naming which one. Overwriting a key reclaims its old bytes first, and only a new key counts against the entry cap.

Shell
drift backbone cache set    greeting "hello" --ttl 3600
drift backbone cache get    greeting
drift backbone cache exists greeting
drift backbone cache del    greeting

Cache is for speed, not durability.

Treat it as data you can always recompute. For anything you can't lose, use NoSQL, SQL, or Blobs.