Simulated Redis: every round trip takes 400ms.
const name = yield* redis.set("{user:42}:name", "Ada");
const visits = yield* redis.incr("{user:42}:visits");
const plan = yield* redis.get("{user:42}:plan");
Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.
A native client with typed commands and scoped connections. One API for every server below.
When a connection drops
Before the write: unsent, safe to retry. After it: possibly-written, so it is never sent twice.
01Playground
Simulated Redis: every round trip takes 400ms.
const name = yield* redis.set("{user:42}:name", "Ada");
const visits = yield* redis.incr("{user:42}:visits");
const plan = yield* redis.get("{user:42}:plan");
Inspired by Kit Langton's Visual Effect
02The API
const User = Schema.Struct({ name: Schema.String, active: Schema.Boolean });
const userKey = RedisKey.json("user:42", User);
const saveUser = Effect.gen(function* () {
const redis = yield* Redis;
yield* redis.setKey(userKey, { name: "Ada", active: true });
return yield* redis.getKey(userKey);
// ^? Option<{ name: string; active: boolean }>
});
// Option<{ name: string; active: boolean }>
03Runtimes
Pick where it runs. Only the Layer changes.
import { Config, Effect } from "effect";
import { Redis } from "@effect-kit/redis";
import { RedisNode } from "@effect-kit/redis/node";
const program = Effect.gen(function* () {
const redis = yield* Redis;
return yield* redis.incr("visits");
});
const RedisLive = RedisNode.layerConfig(
Config.all({ url: Config.String("REDIS_URL") }),
);
program.pipe(Effect.provide(RedisLive));
04Cluster
Type two keys. Put a {hash tag} in both to keep them together.
Different slots. A command that needs both fails with ClusterError cross-slot before it is sent.
05Supported
Servers
Hosted
Runtimes