drift Docs
Start
What is Drift?
The tour, if you are new here.
Why Drift?
The case for a smaller cloud.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, five unit prices, two rules.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Accounts, tokens and scopes.
Security
Boundaries, sandboxing and hardening.

Cache

drift.Backbone.Cache: a key/value store of strings with an optional TTL.

Signatures

Go
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 SDKs

Three ways it differs by language

  • Deletion is Del in Go and delete in the other five: a different identifier, not a re-spelling.
  • Ruby's Cache.set takes its TTL as a required keyword argument: Drift::Backbone::Cache.set(key, value, ttl: 3600). The others take it positionally.
  • Rust's cache::get returns Option<Value>, so a miss is None rather 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.