Supporting Tedis
Introduction
What is tedis
Tedis write with typescript, it's the client of redis for nodejs, support asycn with ts and commonjs
Installation
yarn add tedis
Getting started
commonjs
const { Tedis, TedisPool } = require("tedis");
typescript
import { Tedis, TedisPool } from "tedis";
const tedis = new Tedis({
port: 6379,
host: "127.0.0.1"
});
const tedis = new Tedis({
port: 6379,
host: "127.0.0.1",
password: "your_password"
});
TedisPool
const pool = new TedisPool({
port: 6379,
host: "127.0.0.1"
});
const pool = new TedisPool({
port: 6379,
host: "127.0.0.1",
password: "your_password"
});
const tedis = await pool.getTedis();
pool.putTedis(tedis);
Example
await tedis.command("SET", "key1", "Hello");
await tedis.command("SET", "key2", "World");
await tedis.keys("*");
await tedis.exists("a");
await tedis.set("mystring", "hello");
await tedis.get("mystring");
await tedis.hmset("myhash", {
name: "tedis",
age: 18
});
await tedis.hgetall("myhash");
await tedis.lpush("mylist", "hello", "a", "b", "c", "d", 1, 2, 3, 4);
await tedis.llen("mylist");
Type interface
base
pool
key
string
hash
list
set
zset