Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

RedisSessionClient

interfaz

Interfaz mínima de un cliente Redis para RedisSessionStore: get, set con PX, del y eval. node-redis 4 o posterior la cumple; también un adaptador sobre la API REST de Upstash.

ts
import type { RedisSessionClient } from "@meekojs/meeko/server";

Source code src/server/runtime/session-stores.ts:32

Declaración #

ts
interface RedisSessionClient {
	get(key: string): Promise<string | null>
	set(key: string, value: string, options: { PX: number }): Promise<unknown>
	del(key: string): Promise<unknown>
	eval(script: string, options: { keys: string[]; arguments: string[] }): Promise<unknown>
	quit?(): Promise<unknown>
}

Example #

ts
import type { RedisSessionClient } from "@meekojs/meeko/server";

function upstashClient(url: string, token: string): RedisSessionClient {
  const command = async (...args: Array<string | number>): Promise<unknown> => {
    const response = await fetch(url, { method: "POST", headers: { authorization: `Bearer ${token}` }, body: JSON.stringify(args) });
    return ((await response.json()) as { result?: unknown }).result;
  };
  return {
    get: async (key) => (await command("GET", key)) as string | null,
    set: (key, value, { PX }) => command("SET", key, value, "PX", PX),
    del: (key) => command("DEL", key),
    eval: (script, { keys, arguments: args }) => command("EVAL", script, keys.length, ...keys, ...args),
  };
}

Miembros #

get #

método

get(key: string): Promise<string | null>

Lee una clave, o null si no existe.

set #

método

set(key: string, value: string, options: { PX: number }): Promise<unknown>

Escribe una clave con caducidad en milisegundos.

del #

método

del(key: string): Promise<unknown>

Borra una clave.

eval #

método

eval(script: string, options: { keys: string[]; arguments: string[] }): Promise<unknown>

Ejecuta un script Lua de forma atómica.

quit #

método opcional

quit?(): Promise<unknown>

Cierra la conexión; sólo se usa con closeClient.

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/server/runtime/session-stores.ts