An experimental implementation of redis client for deno
Branch: master
Clone or download
Latest commit eef26d0 Jan 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea add: files Dec 29, 2018
.gitignore wip: generate by code Dec 31, 2018
.travis.yml ci: udpate deno version Jan 15, 2019
LICENSE Initial commit Dec 29, 2018
Makefile feat: pipeline Jan 4, 2019
README.md feat: tx Jan 4, 2019
errors.ts feat: pubsub Jan 2, 2019
io.ts deps: update packages Jan 15, 2019
pipeline.ts deps: update packages Jan 15, 2019
pipeline_test.ts deps: update packages Jan 15, 2019
pubsub.ts deps: update packages Jan 15, 2019
pubsub_test.ts deps: update packages Jan 15, 2019
redis.ts deps: update packages Jan 15, 2019
redis_test.ts deps: update packages Jan 15, 2019
tsconfig.json feat: pipeline Jan 4, 2019

README.md

deno-redis

Build Status

An experimental implementation of redis client for deno

Usage

needs --allow-net privilege

Stateless Commands

import {connect} from "https://denopkg.com/keroxp/deno-redis/redis.ts"
const redis = await connect("127.0.0.1:6379");
const ok = await redis.set("hoge","fuga")
const fuga = await redis.get("hoge");

PubSub

const sub = await redis.subscribe("channel");
(async function() {
  for await (const {channel, message} of sub.receive()) {
    // on message
  }
})()

Advanced Usage

Pipelining

https://redis.io/topics/pipelining

const redis = await connect("127.0.0.1:6379");
const pl = redis.pipeline();
await Promise.all([
    pl.ping(),
    pl.ping(),
    pl.set("set1", "value1"),
    pl.set("set2", "value2"),
    pl.mget("set1", "set2"),
    pl.del("set1"),
    pl.del("set2")
]);
const replies = await pl.flush();

TxPipeline (pipeline with MULTI/EXEC)

We recommend to use tx() instead of multi()/exec() for transactional operation.
MULTI/EXEC are potentially stateful operation so that operation's atomicity is guaranteed but redis's state may change between MULTI and EXEC.

WATCH is designed for these problems. You can ignore it by using TxPipeline because pipelined MULTI/EXEC commands are strictly executed in order at the time and no changes will happen during execution.

See detail https://redis.io/topics/transactions

const tx = redis.tx();
await Promise.all([
   tx.set("a", "aa"),
   tx.set("b", "bb"),
   tx.del("c"),
])
await tx.flush();
// MULTI
// SET a aa
// SET b bb
// DEL c
// EXEC

Compatibility Table (5.0.3)

Connection

  • AUTH
  • ECHO
  • PING
  • QUIT
  • SELECT
  • SWAPDB

Keys

  • DEL
  • DUMP
  • EXISTS
  • EXPIRE
  • EXPIREAT
  • KEYS
  • MIGRATE
  • MOVE
  • OBJECT
  • PERSIST
  • PEXPIRE
  • PEXPIREAT
  • PTTL
  • RANDOMKEY
  • RENAME
  • RENAMENX
  • RESTORE
  • SORT
  • TOUCH
  • TTL
  • TYPE
  • UNLINK
  • WAIT
  • SCAN

String

  • APPEND
  • BITCOUNT
  • BITFIELD
  • BITOP
  • BITPOS
  • DECR
  • DECRBY
  • GET
  • GETBIT
  • GETRANGE
  • GETSET
  • INCR
  • INCRBY
  • INCRBYFLOAT
  • MGET
  • MSET
  • MSETNX
  • PSETEX
  • SET
  • SETBIT
  • SETEX
  • SETNX
  • SETRANGE
  • STRLEN

List

  • BLPOP
  • BRPOP
  • BRPOPLPUSH
  • LINDEX
  • LINSERT
  • LLEN
  • LPOP
  • LPUSH
  • LPUSHX
  • LRANGE
  • LREM
  • LSET
  • LTRIM
  • RPOP
  • RPOPLPUSH
  • RPUSH
  • RPUSHX

Set

  • SADD
  • SCARD
  • SDIFF
  • SDIFFSTORE
  • SINTER
  • SINTERSTORE
  • SISMEMBER
  • SMEMBERS
  • SMOVE
  • SPOP
  • SRANDMEMBER
  • SREM

SortedSet

  • BZPOPMIN
  • BZPOPMAX
  • ZADD
  • ZCARD
  • ZCOUNT
  • ZINCRBY
  • ZINTERSTORE
  • ZLEXCOUNT
  • ZPOPMAX
  • ZPOPMIN
  • ZRANGE
  • ZRANGEBYLEX
  • ZREVRANGEBYLEX
  • ZRANGEBYSCORE
  • ZRANK
  • ZREM
  • ZREMRANGEBYLEX
  • ZREMRANGEBYRANK
  • ZREMRANGEBYSCORE
  • ZREVRANGE
  • ZREVRANGEBYSCORE
  • ZREVRANK
  • ZSCORE
  • ZUNIONSTORE
  • ZSCAN

HashMap

  • HDEL
  • HEXISTS
  • HGET
  • HGETALL
  • HINCRBY
  • HINCRBYFLOAT
  • HKEYS
  • HLEN
  • HMGET
  • HMSET
  • HSET
  • HSETNX
  • HSTRLEN
  • HVALS
  • HSCAN

GEO

  • GEOADD
  • GEOADD
  • GEOHASH
  • GEOPOS
  • GEODIST
  • GEORADIUS
  • GEORADIUSBYMEMBER

Stream

WIP

Server

WIP

Cluster

None

HyperLogLog

  • PFADD
  • PFCOUNT
  • PFMERGE

Multi

  • MULTI
  • EXEC
  • DISCARD
  • WATCH
  • UNWATCH

PubSub

  • PSUBSCRIBE
  • PUBSUB
  • PUBLISH
  • PUNSUBSCRIBE
  • SUBSCRIBE
  • UNSUBSCRIBE

Scripting

  • EVAL
  • EVALSHA
  • SCRIPT DEBUG
  • SCRIPT EXISTS
  • SCRIPT FLUSH
  • SCRIPT KILL
  • SCRIPT LOAD