8000 GitHub - lteam-typescript/redis: Provide typescript and promisify redis wrapper
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

lteam-typescript/redis

Repository files navigation

promisify-redis

Provide typescript and promisify redis wrapper

npm install git+https://github.com/lteam18/redis-promise-typescript.git

Create a redis client with retry strategy


A sample usage

import * as u from "./index"

(async () => {
    let redisClient: u.redis.RedisClient | null = null
    try {
        redisClient = u.createClient()
        console.log(await redisClient.appendAsync("12", "123"))
        await u.sleep(3000)
        console.log(await redisClient.setAsync("12", "456"))
        console.log(await redisClient.getAsync("12"))

        console.log(await redisClient.hsetAsync("a", "b", "c"))
        console.log(await redisClient.hgetAsync("a", "b"))
    } catch (err) {
        console.log(err)
        console.trace(err)
    } finally {
        if (redisClient !== null) {
            await redisClient.quitAsync()
        }
    }
})()

Yet another more advanced library handy-client

https://github.com/mmkal/handy-redis is a remarkable. The codes and tests are auto generated.

但是,考虑到如下几点:

  1. handy-redis维护代价较高
  2. handy-redis采用的是自造promisify-all,而我们采用的则是维护更好的bludbird.promisifyAll
  3. 我们这种手写typedef的上述问题相对而言并不大,而且技术简单文件少,反而不容易出错。
  4. 也许会跟不上最新client变化 - 幸好redis已经很稳定了
  5. 也许会出现def错误 - 不断维护即可,这种问题是有限的

因此,综上,我们决定坚持使用并维护promisify-redis,虽然我们非常钦佩handy-redis的技术含量

About

Provide typescript and promisify redis wrapper

Resources

Stars

Watchers

Forks

Packages

No packages published
0