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

Hashes

Look up the hash commands, including field expiry, with their commands and reply types.

Hash commands store field and value pairs under one key. Fields and values come back as bytes unless the method says text.

Example (Writing and Reading Hash Fields)

import {  } from "effect";

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

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

  const added = yield* .("user:42", [
const added: bigint
["name", "Ada"], ["plan", "pro"], ]); const name = yield* .("user:42", "name");
const name: Option<string>
const everything = yield* .("user:42");
const everything: readonly (readonly [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>])[]
return { , , }; });

hset returns the number of new fields as a bigint. hgetall keeps field order and returns binary pairs, not a JavaScript object.

Methods

MethodCommandReply typePurpose
redis.hsetHSETbigintSet one or more fields.
redis.hmsetHMSETvoidSet one or more fields (older form of HSET).
redis.hsetnxHSETNXbooleanSet a field only if it does not exist.
redis.hgetHGETOption<Uint8Array>Read a field as bytes.
redis.hgetTextHGETOption<string>Read a field as UTF-8 text.
redis.hmgetHMGETreadonly Option<Uint8Array>[]Read several fields in order.
redis.hgetallHGETALLreadonly (readonly [Uint8Array, Uint8Array])[]Read every field and value as pairs.
redis.hkeysHKEYSreadonly Uint8Array[]List the field names.
redis.hvalsHVALSreadonly Uint8Array[]List the values.
redis.hlenHLENbigintCount the fields.
redis.hstrlenHSTRLENbigintReturn the length of a field value.
redis.hexistsHEXISTSbooleanCheck whether a field exists.
redis.hdelHDELbigintDelete fields and return how many were removed.
redis.hincrbyHINCRBYbigintIncrement an integer field.
redis.hincrbyfloatHINCRBYFLOATstringIncrement a field by a decimal amount; the result is the server's decimal text.
redis.hrandfieldHRANDFIELDOption<Uint8Array>Return one random field name.
redis.hrandfieldCountHRANDFIELDreadonly Uint8Array[]Return several random field names.
redis.hrandfieldWithValuesHRANDFIELDreadonly (readonly [Uint8Array, Uint8Array])[]Return several random fields with their values.
redis.hscanHSCANScanPage<readonly [Uint8Array, Uint8Array]>Read one cursor page of fields and values.
redis.hscanFieldsHSCANScanPage<Uint8Array>Read one cursor page of field names only (NOVALUES).
redis.hexpireHEXPIREreadonly bigint[]Set a field expiry in seconds.
redis.hpexpireHPEXPIREreadonly bigint[]Set a field expiry in milliseconds.
redis.hexpireatHEXPIREATreadonly bigint[]Set a field expiry as a Unix time in seconds.
redis.hpexpireatHPEXPIREATreadonly bigint[]Set a field expiry as a Unix time in milliseconds.
redis.httlHTTLreadonly bigint[]Read field expiries in seconds.
redis.hpttlHPTTLreadonly bigint[]Read field expiries in milliseconds.
redis.hexpiretimeHEXPIRETIMEreadonly bigint[]Read field expiries as Unix times in seconds.
redis.hpexpiretimeHPEXPIRETIMEreadonly bigint[]Read field expiries as Unix times in milliseconds.
redis.hpersistHPERSISTreadonly bigint[]Remove field expiries.
redis.hgetdelHGETDELreadonly Option<Uint8Array>[]Read fields and delete them.
redis.hgetexHGETEXreadonly Option<Uint8Array>[]Read fields and change their expiry.
redis.hsetexHSETEXbooleanSet fields with an optional condition and expiry.

HashSetExpiryOptions

redis.hsetex takes HashSetExpiryOptions. Field expiry methods take a HashFields tuple of field names and an optional HashExpireCondition of "NX" | "XX" | "GT" | "LT". redis.hgetex takes an Expiry.

Prop

Type

Scan options

redis.hscan and redis.hscanFields take a cursor string (default "0") and ScanOptions: { match?: RedisArgument; count?: number | bigint }. They return a ScanPage<A>: { cursor: string; entries: ReadonlyArray<A> }. To walk a whole hash as a stream, use redis.scanHash and redis.scanHashFields. See Scanning.