Skip to content

Redis

@zugriff/redis

This package is part of the zugriff ecosystem. It runs on both Edge Runtimes using the fetch API and your machine using the fetch API or the ioredis package.

Usage

Terminal window
npm i --save @zugriff/redis

Creating a client

import { Redis } from '@zugriff/redis';
const client = new Redis(
process.env.ZUGRIFF_REDIS_TOKEN || {
host: 'localhost',
port: 6379,
}
);

Executing a command

await client.cmd('SET', 'number', 1); // { anchor: 'id', data: 'OK' }
await client.cmd('SET', 'json', { hello: 'world' }); // { anchor: 'id', data: 'OK' }

Querying a value

const value = await client.cmd<number>('GET', 'number'); // { anchor: 'id', data: 1 }
const value = await client.cmd<{ hello: string }>('GET', 'json'); // { anchor: 'id', data: { hello: 'world' } }