How to use the async-redis.decorate function in async-redis

To help you get started, we’ve selected a few async-redis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linksmart / border-gateway / bgw-auth-service / validate.js View on Github external
retry_strategy: function (options) {
        if (options.total_retry_time > 1000 * 60) {
            // End reconnecting after a specific timeout and flush all commands
            // with a individual error
            logger.log('error', 'Retry time exhausted');
            return new Error('Retry time exhausted');
        }
        if (options.attempt > 1000) {
            // End reconnecting with built in error
            return undefined;
        }
        // reconnect after
        return Math.min(options.attempt * 100, 3000);
    }
});
asyncRedis.decorate(redisClient);


function generateAES256KeyBuffer(key) {
    let bufferedKey = Buffer.from(key);

    while (bufferedKey.length < 32) {
        key = key + key;
        bufferedKey = Buffer.from(key)
    }
    key = key.substring(0, 32);
    return Buffer.from(key);
}

function encrypt(value, key) {
    let iv = crypto.randomBytes(16);
    let cipher = crypto.createCipheriv(algorithm, generateAES256KeyBuffer(key), iv);
github linksmart / border-gateway / bgw-configuration-service / index.js View on Github external
if (options.total_retry_time > 1000 * 60) {
                // End reconnecting after a specific timeout and flush all commands
                // with a individual error
                logger.log('error', 'Retry time exhausted');
                return new Error('Retry time exhausted');
            }
            if (options.attempt > 1000) {
                // End reconnecting with built in error
                return undefined;
            }
            // reconnect after
            return Math.min(options.attempt * 100, 3000);
        }
    });

    asyncRedis.decorate(redisClient);

    redisClient.on('ready', function () {
        logger.log('debug', 'redisClient is ready');
    });

    redisClient.on('connect', function () {
        logger.log('debug', 'redisClient is connected');
    });

    redisClient.on('reconnecting', function () {
        logger.log('debug', 'redisClient is reconnecting');
    });

    redisClient.on('error', function (error) {
        logger.log('error', 'Error in redisClient', {error:error});
    });
github connect-foundation / 2019-21 / backend / redis / redisClient.js View on Github external
import redis from "redis";
import asyncRedis from "async-redis";
import getLogger from "../libs/logger.js";
import config from "./config";

const client = redis.createClient(config.port, config.host);
const asyncRedisClient = asyncRedis.decorate(client);

const logger = getLogger("socket.io-redis");

asyncRedisClient.on("ready", () => {
	logger.info("redis client now ready");
});

asyncRedisClient.on("connect", () => {
	logger.info("redis client connected");
});

asyncRedisClient.on("error", err => {
	logger.info(err);
});

asyncRedisClient.on("reconnecting", ({delay, attempt}) => {
github linksmart / border-gateway / bgw-rabbitmq-auth-backend-http / index.js View on Github external
const config = require('./config');
const {AAA, CAT} = require('../bgw-aaa-client');
const app = require('express')();
const axios = require('axios');
const crypto = require('crypto');
const bodyParser = require('body-parser');
const redis = require("redis");
const asyncRedis = require("async-redis");
let redisClient;

if (config.redis_host) {
    redisClient = redis.createClient({port: config.redis_port, host: config.redis_host});
    asyncRedis.decorate(redisClient);
}

async function retrieveRules(username) {
    let rules;
    try {
        const hash = crypto.createHash('sha256');
        hash.update(username);
        const redisKey = hash.digest('hex');

        rules = await redisClient.get(redisKey);
        let rulesArray = JSON.parse(rules);
        AAA.log(CAT.DEBUG,'rabbitmq-auth-backend-http', "typeof rules", typeof rules);
        const ttl = await redisClient.ttl(redisKey);
        AAA.log(CAT.DEBUG,'rabbitmq-auth-backend-http', "Retrieved rules ", rulesArray, " for username ", username, " from redis, ttl is ", ttl);
    }
    catch (err) {

async-redis

Light wrapper over redis_node with first class async & promise support.

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular async-redis functions