1import type * as Effect from "effect/Effect";
2import * as Binding from "../Binding.ts";
3import type { ReadRedisClient } from "./ReadRedis.ts";
4import type { Redis } from "./Redis.ts";
5import type { WriteRedisClient } from "./WriteRedis.ts";
6
7/**
8 * Bind a {@link Redis} database with read + write access.
9 *
10 * `ReadWriteRedis` is the Context tag, the type, and the callable —
11 * `yield* Fly.ReadWriteRedis(Cache)`. Provide {@link ReadWriteRedisHttp}.
12 *
13 *
14 * ### Read and write
15 * **Example:** Round-trip a key
16 * ```typescript
17 * const cache = yield* Fly.ReadWriteRedis(Cache);
18 * yield* cache.set("marker", "hello");
19 * const value = yield* cache.get("marker");
20 * ```
21 *
22 * @binding
23 * @product Redis
24 */
25export interface ReadWriteRedis extends Binding.Service<
26 ReadWriteRedis,
27 "Fly.ReadWriteRedis",
28 (redis: Redis) => Effect.Effect<ReadWriteRedisClient>
29> {}
30
31export const ReadWriteRedis =
32 Binding.Service<ReadWriteRedis>("Fly.ReadWriteRedis");
33
34export interface ReadWriteRedisClient
35 extends ReadRedisClient, WriteRedisClient {}