1.0.8 • Published 3 years ago

redis-provider v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

redis-provider

Also see: https://github.com/guylev008/redis-provider

Install

$ npm i redis-provider

Usage simple example

Each DB connection have it's own name.

const redisProvider = require('redis-provider');

const clientName = 'client';
const config = {
	clientName: clientName,
	host: 'localhost',
	port: 6379,
	password: '',
	timeout: 90000,
	retries: 10,
	delay: 100,
	dbNumber: 0
};

redisProvider.createClient(config);

await redisProvider.setAsync(clientName, 'key', 'value');

Aquire Lock

aquireLockAsync needs to be provided with a lock key and a callback function that will run during the lock

const redisProvider = require('redis-provider');

const clientName = 'client';
const config = {
	clientName: clientName,
	host: 'localhost',
	port: 6379,
	password: '',
	timeout: 90000,
	retries: 10,
	delay: 100,
	dbNumber: 0
};

redisProvider.createClient(config);

const setKey = async () => {
	await redisProvider.setAsync(clientName, 'key', 'value');
};

await redisProvider.aquireLockAsync(clientName, 'lock:key', setKey);
1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago