Skip to content

stockholmux/async_node_redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async_node_redis

Use node_redis in modern ways.

Introduction

node_redis is a widely used Redis client for Node.js. It has a very extensible interface and is written in pure JS. It's a little long in the tooth as well - it uses error-first callbacks which makes it a pain to integrate with a promise or async / await script. Until now :cue dramatic music:

How it works

async_node_redis is a shim that makes node_redis graceful in async / await scripts. When I say shim - I mean it: it's tiny - ~39 lines of code. Instead of re-implementing anything, it relies on Proxy Objects and Reflection. This means if you look at the objects, they look like node_redis objects because they are.

Usage

Use as you would node_redis, but without callbacks:

const client = asyncNodeRedis.createClient();
(async () => {
  await client.set('test1','123');
  let foo = await client.get('test1');
  console.log(foo)
})();

It even works with multi / exec:

const client = asyncNodeRedis.createClient();
(async () => {
  let results = await client.multi()
    .get('foo')
    .get('bar')
    .exec();
  console.log(results)
})();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published