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

Lists

Look up the list commands and the blocking list commands on RedisSessions.

List commands push and pop elements at either end and move elements between lists. Elements are bytes.

Example (Pushing and Popping)

import {  } from "effect";

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

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

  const length = yield* .("jobs", ["resize", "email", "index"]);
const length: bigint
const next = yield* .("jobs");
const next: Option<Uint8Array<ArrayBufferLike>>
const batch = yield* .("jobs", 2);
const batch: Option<readonly Uint8Array<ArrayBufferLike>[]>
return { , , }; });

lpop returns Option<Uint8Array> and lpopCount returns Option<readonly Uint8Array[]>, because a count changes the reply from one optional element to an optional aggregate.

Methods

MethodCommandReply typePurpose
redis.lpushLPUSHbigintPush values onto the head.
redis.rpushRPUSHbigintPush values onto the tail.
redis.lpushxLPUSHXbigintPush onto the head only if the list exists.
redis.rpushxRPUSHXbigintPush onto the tail only if the list exists.
redis.lpopLPOPOption<Uint8Array>Pop one element from the head.
redis.rpopRPOPOption<Uint8Array>Pop one element from the tail.
redis.lpopCountLPOPOption<readonly Uint8Array[]>Pop several elements from the head.
redis.rpopCountRPOPOption<readonly Uint8Array[]>Pop several elements from the tail.
redis.llenLLENbigintReturn the list length.
redis.lindexLINDEXOption<Uint8Array>Read the element at an index.
redis.lrangeLRANGEreadonly Uint8Array[]Read a range of elements.
redis.ltrimLTRIMvoidKeep only a range of elements.
redis.lsetLSETvoidSet the element at an index.
redis.lremLREMbigintRemove matching elements and return how many were removed.
redis.linsertLINSERTbigintInsert before or after a pivot element.
redis.lposLPOSOption<bigint>Find the index of an element.
redis.lposCountLPOSreadonly bigint[]Find several indexes of an element.
redis.lmoveLMOVEOption<Uint8Array>Pop from one list and push onto another.
redis.rpoplpushRPOPLPUSHOption<Uint8Array>Pop from the tail of one list and push onto the head of another.
redis.lmovemLMOVEMOption<readonly Uint8Array[]>Move several elements between lists.
redis.lmpopLMPOPOption<readonly [Uint8Array, readonly Uint8Array[]]>Pop elements from the first non-empty list.

Blocking commands

Blocking commands need a session

redis.blpop and the other blocking commands do not exist on Redis. They hold a connection while they wait, so they live on RedisSessions and take BlockingOptions. See Sessions.

These methods are on RedisSessions. Each takes BlockingOptions and returns None when the wait ends with nothing to pop.

MethodCommandReply typePurpose
sessions.blpopBLPOPOption<readonly [Uint8Array, Uint8Array]>Pop from the head of the first non-empty list, waiting if all are empty.
sessions.brpopBRPOPOption<readonly [Uint8Array, Uint8Array]>Pop from the tail of the first non-empty list, waiting if all are empty.
sessions.brpoplpushBRPOPLPUSHOption<Uint8Array>Move the tail of one list to the head of another, waiting for an element.
sessions.blmoveBLMOVEOption<Uint8Array>Move an element between lists, waiting for an element.
sessions.blmovemBLMOVEMOption<readonly Uint8Array[]>Move several elements between lists, waiting for elements.
sessions.blmpopBLMPOPOption<readonly [Uint8Array, readonly Uint8Array[]]>Pop several elements from the first non-empty list, waiting if all are empty.

Example (Waiting for a Job)

import { ,  } from "effect";

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

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

  const job = yield* .(["jobs"], { : .(5) });
const job: Option<readonly [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>]>
return ; });

BlockingOptions

Prop

Type

Option types

  • ListEnd is "LEFT" | "RIGHT", used by lmove, lmovem, lmpop and blmove.
  • ListMoveOptions for lmovem and blmovem: { selection: "COUNT" | "EXACTLY"; count: number | bigint; ordering: "OBO" | "BULK" }.
  • ListPositionOptions for lpos and lposCount: { rank?: number | bigint; maxLength?: number | bigint }.