Skip to content

Fly.Redis reference

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.

const cache = yield* Fly.ReadRedis(Cache);
const value = yield* cache.get("marker");

Source: src/Fly/ReadRedisHttp.ts Kind: Layer · Provides: Fly.ReadRedis

HTTP implementation of ReadRedis.

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.

const cache = yield* Fly.ReadWriteRedis(Cache);
yield* cache.set("marker", "hello");
const value = yield* cache.get("marker");

Source: src/Fly/ReadWriteRedisHttp.ts Kind: 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.

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");

Pass name when you want a stable Upstash database name.

const cache = yield* Fly.Redis("Cache", {
name: "my-cache",
primaryRegion: "iad",
});

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)),
) {}

Enable eviction for cache workloads. Updated in place.

const cache = yield* Fly.Redis("Cache", {
eviction: true,
});

readRegions are extra replica regions. Updated in place.

const cache = yield* Fly.Redis("Cache", {
primaryRegion: "iad",
readRegions: ["sjc"],
});

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",
});

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.

const cache = yield* Fly.WriteRedis(Cache);
yield* cache.set("marker", "hello");

Source: src/Fly/WriteRedisHttp.ts Kind: Layer · Provides: Fly.WriteRedis

HTTP implementation of WriteRedis.