Skip to content

🔴 Redis API ​

Full IORedis-compatible command surface. Unknown method names are forwarded as registered custom hooks.

Connection ​

ping ​

Health check; returns PONG.

ts
ping(): Promise<string>
ts
const redis = zedgi.redis();
const pong = await redis.ping(); // 'PONG'
python
redis = zedgi.redis()
pong = redis.ping()  # 'PONG'
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "ping",
  "payload": {
    "args": []
  }
}

Strings ​

get ​

Get the string value of a key.

ts
get(key): Promise<string | null>
ts
const redis = zedgi.redis();
const v = await redis.get('user:1:name');
python
redis = zedgi.redis()
v = redis.get('user:1:name')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "get",
  "payload": {
    "args": [
      "user:1:name"
    ]
  }
}

set ​

Set the string value of a key. Extra args map to Redis options (EX, NXâ€Ļ).

ts
set(key, value, ...opts)
ts
const redis = zedgi.redis();
await redis.set('session:abc', token, 'EX', 3600);
python
redis = zedgi.redis()
redis.set('session:abc', token, 'EX', 3600)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "set",
  "payload": {
    "args": [
      "session:abc",
      "token",
      "EX",
      3600
    ]
  }
}

append ​

Append a value to a key.

ts
append(key, value): Promise<number>
ts
const redis = zedgi.redis();
await redis.append('log', 'line\n');
python
redis = zedgi.redis()
redis.call('APPEND', 'log', 'line\n')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "append",
  "payload": {
    "args": [
      "log",
      "line\n"
    ]
  }
}

incr ​

Increment the integer value of a key by one.

ts
incr(key): Promise<number>
ts
const redis = zedgi.redis();
const n = await redis.incr('views');
python
redis = zedgi.redis()
n = redis.incr('views')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "incr",
  "payload": {
    "args": [
      "views"
    ]
  }
}

incrby ​

Increment the integer value of a key by the given amount.

ts
incrby(key, amount): Promise<number>
ts
const redis = zedgi.redis();
await redis.incrby('score', 10);
python
redis = zedgi.redis()
redis.call('INCRBY', 'score', 10)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "incrby",
  "payload": {
    "args": [
      "score",
      10
    ]
  }
}

decr ​

Decrement the integer value of a key by one.

ts
decr(key): Promise<number>
ts
const redis = zedgi.redis();
await redis.decr('stock');
python
redis = zedgi.redis()
redis.call('DECR', 'stock')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "decr",
  "payload": {
    "args": [
      "stock"
    ]
  }
}

mget ​

Get the values of multiple keys.

ts
mget(...keys): Promise<(string|null)[]>
ts
const redis = zedgi.redis();
await redis.call('MGET', 'a', 'b', 'c');
python
redis = zedgi.redis()
redis.call('MGET', 'a', 'b', 'c')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "mget",
  "payload": {
    "args": [
      "a",
      "b",
      "c"
    ]
  }
}

setex ​

Set a key with an expiry in seconds.

ts
setex(key, seconds, value)
ts
const redis = zedgi.redis();
await redis.call('SETEX', 'otp', 300, code);
python
redis = zedgi.redis()
redis.call('SETEX', 'otp', 300, code)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "setex",
  "payload": {
    "args": [
      "otp",
      300,
      "code"
    ]
  }
}

Keys ​

del ​

Delete one or more keys.

ts
del(...keys): Promise<number>
ts
const redis = zedgi.redis();
await redis.del('cache:home', 'cache:about');
python
redis = zedgi.redis()
redis.delete('cache:home', 'cache:about')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "del",
  "payload": {
    "args": [
      "cache:home",
      "cache:about"
    ]
  }
}

exists ​

Check whether one or more keys exist.

ts
exists(...keys): Promise<number>
ts
const redis = zedgi.redis();
await redis.exists('user:1');
python
redis = zedgi.redis()
redis.call('EXISTS', 'user:1')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "exists",
  "payload": {
    "args": [
      "user:1"
    ]
  }
}

expire ​

Set a key’s time-to-live in seconds.

ts
expire(key, seconds): Promise<number>
ts
const redis = zedgi.redis();
await redis.expire('session:abc', 3600);
python
redis = zedgi.redis()
redis.expire('session:abc', 3600)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "expire",
  "payload": {
    "args": [
      "session:abc",
      3600
    ]
  }
}

ttl ​

Get the remaining time-to-live of a key.

ts
ttl(key): Promise<number>
ts
const redis = zedgi.redis();
const ttl = await redis.ttl('session:abc');
python
redis = zedgi.redis()
ttl = redis.call('TTL', 'session:abc')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "ttl",
  "payload": {
    "args": [
      "session:abc"
    ]
  }
}

keys ​

Find all keys matching a pattern (use sparingly).

ts
keys(pattern): Promise<string[]>
ts
const redis = zedgi.redis();
await redis.call('KEYS', 'user:*');
python
redis = zedgi.redis()
redis.call('KEYS', 'user:*')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "keys",
  "payload": {
    "args": [
      "user:*"
    ]
  }
}

type ​

Get the data type stored at a key.

ts
type(key): Promise<string>
ts
const redis = zedgi.redis();
await redis.call('TYPE', 'mylist');
python
redis = zedgi.redis()
redis.call('TYPE', 'mylist')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "type",
  "payload": {
    "args": [
      "mylist"
    ]
  }
}

Hashes ​

hset ​

Set field-value pairs in a hash.

ts
hset(key, ...fieldValues): Promise<number>
ts
const redis = zedgi.redis();
await redis.hset('user:1', 'name', 'Ada', 'age', '36');
python
redis = zedgi.redis()
redis.call('HSET', 'user:1', 'name', 'Ada')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "hset",
  "payload": {
    "args": [
      "user:1",
      "name",
      "Ada",
      "age",
      "36"
    ]
  }
}

hget ​

Get the value of a hash field.

ts
hget(key, field): Promise<string | null>
ts
const redis = zedgi.redis();
await redis.hget('user:1', 'name');
python
redis = zedgi.redis()
redis.hget('user:1', 'name')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "hget",
  "payload": {
    "args": [
      "user:1",
      "name"
    ]
  }
}

hgetall ​

Get all fields and values of a hash.

ts
hgetall(key): Promise<Record<string,string>>
ts
const redis = zedgi.redis();
const u = await redis.hgetall('user:1');
python
redis = zedgi.redis()
u = redis.hgetall('user:1')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "hgetall",
  "payload": {
    "args": [
      "user:1"
    ]
  }
}

hdel ​

Delete one or more hash fields.

ts
hdel(key, ...fields): Promise<number>
ts
const redis = zedgi.redis();
await redis.hdel('user:1', 'age');
python
redis = zedgi.redis()
redis.call('HDEL', 'user:1', 'age')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "hdel",
  "payload": {
    "args": [
      "user:1",
      "age"
    ]
  }
}

hincrby ​

Increment a hash field by an integer.

ts
hincrby(key, field, amount)
ts
const redis = zedgi.redis();
await redis.call('HINCRBY', 'user:1', 'logins', 1);
python
redis = zedgi.redis()
redis.call('HINCRBY', 'user:1', 'logins', 1)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "hincrby",
  "payload": {
    "args": [
      "user:1",
      "logins",
      1
    ]
  }
}

Lists ​

lpush ​

Prepend one or more values to a list.

ts
lpush(key, ...values): Promise<number>
ts
const redis = zedgi.redis();
await redis.lpush('queue', job);
python
redis = zedgi.redis()
redis.call('LPUSH', 'queue', job)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "lpush",
  "payload": {
    "args": [
      "queue",
      "job"
    ]
  }
}

rpush ​

Append one or more values to a list.

ts
rpush(key, ...values): Promise<number>
ts
const redis = zedgi.redis();
await redis.rpush('queue', job);
python
redis = zedgi.redis()
redis.call('RPUSH', 'queue', job)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "rpush",
  "payload": {
    "args": [
      "queue",
      "job"
    ]
  }
}

lpop ​

Remove and return the first element of a list.

ts
lpop(key): Promise<string | null>
ts
const redis = zedgi.redis();
const job = await redis.lpop('queue');
python
redis = zedgi.redis()
job = redis.call('LPOP', 'queue')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "lpop",
  "payload": {
    "args": [
      "queue"
    ]
  }
}

lrange ​

Get a range of elements from a list.

ts
lrange(key, start, stop): Promise<string[]>
ts
const redis = zedgi.redis();
await redis.lrange('queue', 0, -1);
python
redis = zedgi.redis()
redis.lrange('queue', 0, -1)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "lrange",
  "payload": {
    "args": [
      "queue",
      0,
      -1
    ]
  }
}

llen ​

Get the length of a list.

ts
llen(key): Promise<number>
ts
const redis = zedgi.redis();
await redis.call('LLEN', 'queue');
python
redis = zedgi.redis()
redis.call('LLEN', 'queue')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "llen",
  "payload": {
    "args": [
      "queue"
    ]
  }
}

Sets ​

sadd ​

Add one or more members to a set.

ts
sadd(key, ...members): Promise<number>
ts
const redis = zedgi.redis();
await redis.sadd('tags', 'edge', 'redis');
python
redis = zedgi.redis()
redis.call('SADD', 'tags', 'edge')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "sadd",
  "payload": {
    "args": [
      "tags",
      "edge",
      "redis"
    ]
  }
}

smembers ​

Get all members of a set.

ts
smembers(key): Promise<string[]>
ts
const redis = zedgi.redis();
await redis.smembers('tags');
python
redis = zedgi.redis()
redis.call('SMEMBERS', 'tags')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "smembers",
  "payload": {
    "args": [
      "tags"
    ]
  }
}

sismember ​

Check whether a value is a set member.

ts
sismember(key, member): Promise<number>
ts
const redis = zedgi.redis();
await redis.sismember('tags', 'edge');
python
redis = zedgi.redis()
redis.call('SISMEMBER', 'tags', 'edge')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "sismember",
  "payload": {
    "args": [
      "tags",
      "edge"
    ]
  }
}

Sorted Sets ​

zadd ​

Add a member with a score to a sorted set.

ts
zadd(key, score, member): Promise<number>
ts
const redis = zedgi.redis();
await redis.zadd('leaderboard', 100, 'ada');
python
redis = zedgi.redis()
redis.call('ZADD', 'leaderboard', 100, 'ada')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "zadd",
  "payload": {
    "args": [
      "leaderboard",
      100,
      "ada"
    ]
  }
}

zrange ​

Return a range of members by index.

ts
zrange(key, start, stop): Promise<string[]>
ts
const redis = zedgi.redis();
await redis.zrange('leaderboard', 0, 9);
python
redis = zedgi.redis()
redis.call('ZRANGE', 'leaderboard', 0, 9)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "zrange",
  "payload": {
    "args": [
      "leaderboard",
      0,
      9
    ]
  }
}

zscore ​

Get the score of a member.

ts
zscore(key, member): Promise<string | null>
ts
const redis = zedgi.redis();
await redis.zscore('leaderboard', 'ada');
python
redis = zedgi.redis()
redis.call('ZSCORE', 'leaderboard', 'ada')
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "zscore",
  "payload": {
    "args": [
      "leaderboard",
      "ada"
    ]
  }
}

Advanced ​

call ​

Run any Redis command not exposed as a named method.

ts
call(command, ...args): Promise<unknown>
ts
const redis = zedgi.redis();
await redis.call('SET', 'k', 'v', 'EX', 60);
python
redis = zedgi.redis()
redis.call('SET', 'k', 'v', 'EX', 60)
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "call",
  "payload": {
    "command": "SET",
    "args": [
      "k",
      "v",
      "EX",
      60
    ]
  }
}

pipeline ​

Run several commands in one round-trip (no transaction).

ts
pipeline(commands): Promise<unknown[]>
ts
const redis = zedgi.redis();
await redis.pipeline([
  { command: 'SET', args: ['a', '1'] },
  { command: 'INCR', args: ['a'] },
]);
python
redis = zedgi.redis()
redis._t.call('redis', 'pipeline', {
  'commands': [
    {'command': 'SET', 'args': ['a', '1']},
    {'command': 'INCR', 'args': ['a']},
  ]
})
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "pipeline",
  "payload": {
    "commands": [
      {
        "command": "SET",
        "args": [
          "a",
          "1"
        ]
      },
      {
        "command": "INCR",
        "args": [
          "a"
        ]
      }
    ]
  }
}

multi ​

Run several commands atomically in a MULTI/EXEC transaction.

ts
multi(commands): Promise<unknown[]>
ts
const redis = zedgi.redis();
await redis.multi([
  { command: 'INCR', args: ['orders'] },
  { command: 'RPUSH', args: ['order:log', 'new'] },
]);
python
redis = zedgi.redis()
redis._t.call('redis', 'multi', {
  'commands': [
    {'command': 'INCR', 'args': ['orders']},
    {'command': 'RPUSH', 'args': ['order:log', 'new']},
  ]
})
http
POST /rpc HTTP/1.1
Host: dev123.zedgi.app
x-zedgi-key: zk_live_xxx
content-type: application/json

{
  "service": "redis",
  "method": "multi",
  "payload": {
    "commands": [
      {
        "command": "INCR",
        "args": [
          "orders"
        ]
      },
      {
        "command": "RPUSH",
        "args": [
          "order:log",
          "new"
        ]
      }
    ]
  }
}