How to use async-redis - 9 common examples

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 zKillboard / evewho / app.js View on Github external
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var logger = require('morgan');
var Database = require('./classes/Database.js');
var getJSON = require('get-json');
var redis = require('async-redis').createClient();
const app_path = __dirname;

var indexRouter = require('./routes.js');

var app = express();
app.root = __dirname;
app.redis = redis;

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

app.enable('etag');
app.use(logger('dev'));

const server_started = Date.now();
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 star7th / htq / queue.js View on Github external
/**
 * @author  xing7th@gmail.com
 * @website http://www.showdoc.cc/htq
 */
const asyncRedis = require("async-redis");
const client = asyncRedis.createClient();
const fs = require('fs');
const fetch = require("node-fetch");

const config = JSON.parse(fs.readFileSync('./config.json').toString());
const redis_client = asyncRedis.createClient(config.redis_port,config.redis_host); //creates a new client
console.log("后台队列服务已经启动,随时等待新队列任务");
var queue_status_array = [];

//设置一个循环任务,1天检测一次。当队列空的时候,则停止本进程(父进程会重新启动本进程)
setInterval(function(){
	var isDoing = 0 ;
	for( let x in queue_status_array){
		if (queue_status_array[x]) {
			isDoing = 1 ;
		};
	}
	if (! isDoing ){
		process.exit();
	};
},1*24*60*60*1000);
github star7th / htq / queue.js View on Github external
/**
 * @author  xing7th@gmail.com
 * @website http://www.showdoc.cc/htq
 */
const asyncRedis = require("async-redis");
const client = asyncRedis.createClient();
const fs = require('fs');
const fetch = require("node-fetch");

const config = JSON.parse(fs.readFileSync('./config.json').toString());
const redis_client = asyncRedis.createClient(config.redis_port,config.redis_host); //creates a new client
console.log("后台队列服务已经启动,随时等待新队列任务");
var queue_status_array = [];

//设置一个循环任务,1天检测一次。当队列空的时候,则停止本进程(父进程会重新启动本进程)
setInterval(function(){
	var isDoing = 0 ;
	for( let x in queue_status_array){
		if (queue_status_array[x]) {
			isDoing = 1 ;
		};
	}
github zKillboard / evewho / bin / cron.js View on Github external
#!/usr/bin/env node

var Database = require('../classes/Database.js');
var getJSON = require('get-json');
var redis = require('async-redis').createClient();
var phin = require('phin').defaults({'method': 'get', 'headers': { 'User-Agent': 'evewho.com' } });

const app = {};

app.debug = false;
app.bailout = false;
app.error_count = 0;
app.phin = phin;
app.fetch = async function(url, parser, failure, options) {
    try {
        return await parser(app, await phin(url), options);
    } catch (e) {
        return failure(app, e);
    }
};
app.redis = redis;
github mprove-io / mprove / src / redis-client.ts View on Github external
let redis = require('async-redis');

export const redisClient = redis.createClient({ host: 'redis', port: 6379 });
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