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.

Effect KitRedis

Scripting

Look up the Lua script and function commands, RedisScripts and the script option types.

Scripting commands run Lua on the server, either as scripts you send by source or digest, or as functions in loaded libraries. You declare the keys yourself, because the client cannot infer them from Lua source.

Example (Running a Script With a Typed Reply)

import {  } from "effect";

import { RedisScript, , Reply } from "@effect-kit/redis";

const  = .(function* () {
  const  = yield* ;

  const  = yield* RedisScript.({
    : "return redis.call('INCRBY', KEYS[1], ARGV[1])",
    : Reply.,
  });

  const total = yield* .(, { : ["counter"], : ["5"] });
const total: bigint
return ; });

RedisScript.make computes the SHA-1 digest, so it needs Crypto. The native RedisNode and RedisBun layers provide it. RedisScripts.execute runs the script by digest and loads it first if the server does not have it. The Lua scripts guide covers loading and routing.

Methods on Redis

evalScript, evalSha, evalReadOnly, evalShaReadOnly, fcall and fcallReadOnly take the source, digest or function name, a ScriptArguments value and a reply decoder from the Reply namespace. The reply type A is whatever the decoder returns.

MethodCommandReply typePurpose
redis.evalScriptEVALARun Lua source with declared keys and arguments.
redis.evalShaEVALSHAARun a cached script by SHA-1 digest.
redis.evalReadOnlyEVAL_ROARun Lua source that must not write.
redis.evalShaReadOnlyEVALSHA_ROARun a cached script by digest that must not write.
redis.fcallFCALLACall a loaded function.
redis.fcallReadOnlyFCALL_ROACall a function that must not write.
redis.scriptLoadSCRIPT LOADstringLoad a script and return its SHA-1 digest.
redis.scriptExistsSCRIPT EXISTSreadonly boolean[]Check which digests are cached.
redis.scriptFlushSCRIPT FLUSHvoidClear the script cache.
redis.scriptShowSCRIPT SHOWUint8ArrayReturn the source of a cached script by digest.
redis.scriptKillSCRIPT KILLvoidStop a running read-only script.
redis.scriptHelpSCRIPT HELPreadonly string[]Return the SCRIPT help text.
redis.functionLoadFUNCTION LOADstringLoad a function library and return its name.
redis.functionListFUNCTION LISTreadonly (readonly (readonly [string, RespValue])[])[]List function libraries.
redis.functionDeleteFUNCTION DELETEvoidDelete a library.
redis.functionDumpFUNCTION DUMPUint8ArraySerialize all libraries.
redis.functionRestoreFUNCTION RESTOREvoidRestore libraries from a dump.
redis.functionFlushFUNCTION FLUSHvoidDelete all libraries.
redis.functionKillFUNCTION KILLvoidStop a running read-only function.
redis.functionStatsFUNCTION STATSreadonly (readonly [string, RespValue])[]Return running-function and engine statistics.
redis.functionHelpFUNCTION HELPreadonly string[]Return the FUNCTION help text.

ScriptArguments

Prop

Type

FunctionListOptions for functionList is { libraryName?: string | Uint8Array; withCode?: boolean }. scriptFlush and functionFlush take a mode of "SYNC" or "ASYNC". functionLoad takes (source, replace?). functionRestore takes a dump and a policy of "FLUSH", "APPEND" or "REPLACE".

RedisScripts

MethodReply typePurpose
scripts.executeARun a RedisScript<A, E, R> with { keys, args? }, loading it on demand.

RedisScript<A, E, R> is { source: Redacted<Uint8Array>; sha1: string; readOnly: boolean; decode: ReplyDecoder<A, E, R> }. RedisScript.make takes { source, decode, readOnly? }.

ScriptOptions configures the layer. See scripts.