| 1 | import type * as Effect from "effect/Effect"; |
| 2 | import * as Binding from "../Binding.ts"; |
| 3 | import type { ReadClient } from "../Redis/index.ts"; |
| 4 | import type { Redis } from "./Redis.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Bind a {@link Redis} database with read access (`get`, `ping`). |
| 8 | * |
| 9 | * `ReadRedis` is the Context tag, the type, and the callable — |
| 10 | * `yield* Railway.ReadRedis(Cache)`. Provide {@link ReadRedisHttp}. |
| 11 | * |
| 12 | * |
| 13 | * ### Read |
| 14 | * **Example:** Get a key |
| 15 | * ```typescript |
| 16 | * const cache = yield* Railway.ReadRedis(Cache); |
| 17 | * const value = yield* cache.get("marker"); |
| 18 | * ``` |
| 19 | * |
| 20 | * @binding |
| 21 | * @product Redis |
| 22 | */ |
| 23 | export interface ReadRedis extends Binding.Service< |
| 24 | ReadRedis, |
| 25 | "Railway.ReadRedis", |
| 26 | (redis: Redis) => Effect.Effect<ReadRedisClient> |
| 27 | > {} |
| 28 | |
| 29 | export const ReadRedis = Binding.Service<ReadRedis>("Railway.ReadRedis"); |
| 30 | |
| 31 | export type ReadRedisClient = ReadClient; |