async-await-redis
v1.2.0
Published
Async Await Redis Client
Downloads
1
Readme
Async-Await-Redis
Install
npm i -S async-await-redis
Redis Client
const Redis = require("async-await-redis");
const redis = await Redis.getInstance();
Setting and Getting Keys
Setting key with TTL of 30 seconds
await redis.set('name', 'Leblanc Peterson', 30);
const keys = await redis.keys('name');
Setting multiple keys and fetching keys
await redis.set('name1', 'Graham Elliott', 30);
await redis.set('name2', 'Georgia Guerrero', 30);
await redis.set('name3', 'Henderson Kirby', 30);
const keys = await redis.keys('name*'); // ['name1', 'name2', 'name3']
Delete Key or Keys
await redis.set('namez1', 'Graham Elliott', 30);
await redis.set('namez2', 'Georgia Guerrero', 30);
await redis.set('namez3', 'Henderson Kirby', 30);
await redis.delete('namez*');
const keys = await redis.keys('namez*'); // []
Close Redis Connection
Finally after operation, do not forget to close redis connection as follows
async redis.close();
Other Methods
await redis.pushList('mylist','Henderson');
await redis.popList('mylist','Henderson');
await redis.getList('mylist');
await redis.addToSet('myset','Henderson');
await redis.removeFromSet('myset','Henderson');
await redis.getSet('myset');
await redis.addToSortedSet('myset','a','b','c');
await redis.removeFromSortedSet('myset','a');
await redis.getSortedSet('myset');
await redis.removeSortedSet('myset');