Fly.Redis reference
ReadRedis
Section titled “ReadRedis”Source:
src/Fly/ReadRedis.ts
Bind a Redis database with read access (get, ping).
ReadRedis is the Context tag, the type, and the callable —
yield* Fly.ReadRedis(Cache). Provide ReadRedisHttp.
ReadRedis: Read
Section titled “ReadRedis: Read”const cache = yield* Fly.ReadRedis(Cache);const value = yield* cache.get("marker");ReadRedisHttp
Section titled “ReadRedisHttp”Source:
src/Fly/ReadRedisHttp.tsKind: Layer · Provides:Fly.ReadRedis
HTTP implementation of ReadRedis.
ReadWriteRedis
Section titled “ReadWriteRedis”Source:
src/Fly/ReadWriteRedis.ts
Bind a Redis database with read + write access.
ReadWriteRedis is the Context tag, the type, and the callable —
yield* Fly.ReadWriteRedis(Cache). Provide ReadWriteRedisHttp.
ReadWriteRedis: Read and write
Section titled “ReadWriteRedis: Read and write”const cache = yield* Fly.ReadWriteRedis(Cache);yield* cache.set("marker", "hello");const value = yield* cache.get("marker");ReadWriteRedisHttp
Section titled “ReadWriteRedisHttp”Source:
src/Fly/ReadWriteRedisHttp.tsKind: Layer · Provides:Fly.ReadWriteRedis
HTTP implementation of ReadWriteRedis.
Source:
src/Fly/Redis.ts
Managed Upstash Redis in a Fly org. Bind ReadRedis,
WriteRedis, or ReadWriteRedis on a Service.
Alchemy transports the redacted url Output to the runtime client
and also writes REDIS_URL as an App secret for compatibility.
Redis is not reachable from CI — drive it over HTTP.
Redis: Create Redis
Section titled “Redis: Create Redis”Alchemy generates a unique name unless you pass one. Default region is
iad. Default plan is the cheapest addOnPlans row (free or
pay-as-you-go).
const cache = yield* Fly.Redis("Cache");Redis: A stable name
Section titled “Redis: A stable name”Pass name when you want a stable Upstash database name.
const cache = yield* Fly.Redis("Cache", { name: "my-cache", primaryRegion: "iad",});Redis: Bind from a Service
Section titled “Redis: Bind from a Service”Yield ReadWriteRedis (or ReadRedis / WriteRedis)
in Service init. Provide the matching *Http layer.
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
const Cache = Fly.Redis("Cache");
export default class Api extends Fly.Service<Api>()( "Api", { app: Site, main: import.meta.url, port: 3000 }, Effect.gen(function* () { const cache = yield* Fly.ReadWriteRedis(Cache); return { fetch: Effect.gen(function* () { yield* cache.set("marker", "hello"); const value = yield* cache.get("marker"); return HttpServerResponse.json({ value }); }), }; }).pipe(Effect.provide(Fly.ReadWriteRedisHttp)),) {}Redis: Eviction
Section titled “Redis: Eviction”Enable eviction for cache workloads. Updated in place.
const cache = yield* Fly.Redis("Cache", { eviction: true,});Redis: Read replicas
Section titled “Redis: Read replicas”readRegions are extra replica regions. Updated in place.
const cache = yield* Fly.Redis("Cache", { primaryRegion: "iad", readRegions: ["sjc"],});Redis: Plan
Section titled “Redis: Plan”Omit plan for the cheapest listed plan. Pass a plan id or display
name to pin one. Fixed plans are billed.
const cache = yield* Fly.Redis("Cache", { plan: "Pay-as-you-go",});WriteRedis
Section titled “WriteRedis”Source:
src/Fly/WriteRedis.ts
Bind a Redis database with write access (set, del).
WriteRedis is the Context tag, the type, and the callable —
yield* Fly.WriteRedis(Cache). Provide WriteRedisHttp.
WriteRedis: Write
Section titled “WriteRedis: Write”const cache = yield* Fly.WriteRedis(Cache);yield* cache.set("marker", "hello");WriteRedisHttp
Section titled “WriteRedisHttp”Source:
src/Fly/WriteRedisHttp.tsKind: Layer · Provides:Fly.WriteRedis
HTTP implementation of WriteRedis.