How to use the redis.RedisClient function in redis

To help you get started, we’ve selected a few 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 launchdarkly / node-server-sdk / test-types.ts View on Github external
client.allFlags(user, (flagSet: ld.LDFlagSet) =>  {
  var flagSetValue: ld.LDFlagValue = flagSet['key'];
});

// evaluation methods with promises
client.variation('key', user, false).then((value: ld.LDFlagValue) => { });
client.variation('key', user, 2).then((value: ld.LDFlagValue) => { });
client.variation('key', user, 'default').then((value: ld.LDFlagValue) => { });
client.variationDetail('key', user, 'default').then((detail: ld.LDEvaluationDetail) => { });
client.allFlags(user).then((flagSet: ld.LDFlagSet) => { });

// Redis integration
var redisStore0 = ld.RedisFeatureStore();
var myRedisOpts: redis.ClientOpts = {};
var redisStore1 = ld.RedisFeatureStore(myRedisOpts, 30, 'prefix', logger);
var myRedisClient: redis.RedisClient = new redis.RedisClient(myRedisOpts);
var redisStore2 = ld.RedisFeatureStore(undefined, 30, 'prefix', logger, myRedisClient);
github nicobarray / aquedux / packages / aquedux-server / __tests__ / server.js View on Github external
import http from 'http'
import { applyMiddleware } from 'redux'

import redis from 'redis'
import bluebird from 'bluebird'

bluebird.promisifyAll(redis.RedisClient.prototype)
bluebird.promisifyAll(redis.Multi.prototype)

import { until, once, fakeUserAction } from './utils'

// Public api
import { createAquedux, createStore, close } from '../src'

// Private
import configManager from '../src/managers/configManager'
import channelManager from '../src/managers/channelManager'
import tankManager from '../src/managers/tankManager'
import queueManager from '../src/managers/queueManager'

const counterReducer = (prevState = 0, action) => {
  const { type } = action
  if (type === 'counter/inc') {
github aboutlo / async-memo-ize / packages / async-memo-ize-plugin-redis-cache / lib / index.js View on Github external
constructor() {
    const args = Array.from(arguments)
    if (args[0] instanceof redis.RedisClient) {
      this.client = args[0]
      this.localCache = new LocalCache()
    } else if (args[0] instanceof LocalCache) {
      this.localCache = args[0]
      this.client = redis.createClient.apply(redis, args.splice(1))
    } else if (
      args[0] instanceof Object &&
      !args[0] instanceof redis.RedisClient &&
      args.length === 1
    ) {
      this.localCache = args.localCache
      const redisOptions = omit(args, ['localCache'])
      this.client = redis.createClient(redisOptions)
    } else {
      this.client = redis.createClient.apply(redis, args)
      this.localCache = new LocalCache()
    }

    this.client.on('error', function(err) {
      console.log('Error ' + err)
    })
    this.client.on('ready', function() {
      // console.log('ready')
    })
github FreeFeed / freefeed-server / app / support / DbAdapter / index.js View on Github external
import postsTrait from './posts';
import subscriptionsTrait from './subscriptions';
import localBumpsTrait from './local-bumps';
import searchTrait from './search';
import hashtagsTrait from './hashtags';
import unreadDirectsTrait from './unread-directs';
import statsTrait from './stats';
import eventsTrait from './events';
import commentLikesTrait from './comment-likes';
import allGroupsTrait from './all-groups';
import summaryTrait from './summary';
import invitationsTrait from './invitations';
import accessTokensTrait from './access-tokens';


promisifyAll(redis.RedisClient.prototype);
promisifyAll(redis.Multi.prototype);

class DbAdapterBase {
  constructor(database) {
    this.database = database;
    this.statsCache = promisifyAll(new NodeCache({ stdTTL: 300 }));

    const config = configLoader();

    const CACHE_TTL = 60 * 60 * 24; // 24 hours

    this.memoryCache = cacheManager.caching({ store: 'memory', max: 5000, ttl: CACHE_TTL });
    this.cache = cacheManager.caching({
      store: redisStore,
      host:  config.redis.host,
      port:  config.redis.port,
github iopipe / iopipe-js-trace / src / plugins / redis.js View on Github external
function wrap({ timeline, data = {} } = {}) {
  const target = redis.RedisClient && redis.RedisClient.prototype;

  if (!(timeline instanceof Perf)) {
    debug(
      'Timeline passed to plugins/ioredis.wrap not an instance of performance-node. Skipping.'
    );
    return false;
  }

  if (!redis.__iopipeShimmer) {
    if (process.env.IOPIPE_TRACE_REDIS_CB) {
      shimmer.wrap(target, 'send_command', wrapSendCommand); // redis < 2.5.3
    } else {
      shimmer.wrap(target, 'internal_send_command', wrapInternalSendCommand);
    }
    target.__iopipeShimmer = true;
  }
github MoveOnOrg / Spoke / src / server / models / thinky.js View on Github external
import dumbThinky from "rethink-knex-adapter";
import redis from "redis";
import bluebird from "bluebird";
import config from "../knex-connect";

bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);

// Instantiate the rethink-knex-adapter using the config defined in
// /src/server/knex.js.
const thinkyConn = dumbThinky(config);

thinkyConn.r.getCount = async query => {
  // helper method to get a count result
  // with fewer bugs.  Using knex's .count()
  // results in a 'count' key on postgres, but a 'count(*)' key
  // on sqlite -- ridiculous.  This smooths that out
  if (Array.isArray(query)) {
    return query.length;
  }
  return Number((await query.count("* as count").first()).count);
};
github ankkho / aws-node-elasticache-vpc / aws / redis.js View on Github external
/*
	Returns promise functions for interacting with redis
*/

import redis from 'redis'
import bluebird from 'bluebird'

bluebird.promisifyAll(redis.RedisClient.prototype)
bluebird.promisifyAll(redis.Multi.prototype)

const createRedisClient = () => {
	const clientObj = redis.createClient(6379, process.env.cacheUrl, { no_ready_check: true })

	clientObj.on('error', (err) => {
		console.log(`Error while creating redis client: ${err}`)
	})

	return clientObj
}

const client = createRedisClient()

export default client
github reindexio / reindex-api / db / getRedisClient.js View on Github external
import Promise from 'bluebird';
import redis from 'redis';

import Config from '../server/Config';
import Monitoring from '../Monitoring';

Promise.promisifyAll(redis.RedisClient.prototype);
Promise.promisifyAll(redis.Multi.prototype);

const CLIENTS = {};

export default function getRedisClient(name) {
  if (!CLIENTS[name]) {
    const client = redis.createClient(Config.get('redis.url'));
    client.once('error', (err) => {
      Monitoring.noticeError(err);
      CLIENTS[name] = null;
      client.quit();
    });
    CLIENTS[name] = client;
  }

  return CLIENTS[name];
github lionsharecapital / lionshare-api / db / redis.js View on Github external
import bluebird from "bluebird";
import redis from "redis";

bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);

const client = redis.createClient(process.env.REDIS_URL);

client.on("connect", () => {
  console.log("Redis connected");
});

export default client;
github aboutlo / async-memo-ize / packages / async-memo-ize-plugin-redis-cache / lib / index.js View on Github external
constructor() {
    const args = Array.from(arguments)
    if (args[0] instanceof redis.RedisClient) {
      this.client = args[0]
      this.localCache = new LocalCache()
    } else if (args[0] instanceof LocalCache) {
      this.localCache = args[0]
      this.client = redis.createClient.apply(redis, args.splice(1))
    } else if (
      args[0] instanceof Object &&
      !args[0] instanceof redis.RedisClient &&
      args.length === 1
    ) {
      this.localCache = args.localCache
      const redisOptions = omit(args, ['localCache'])
      this.client = redis.createClient(redisOptions)
    } else {
      this.client = redis.createClient.apply(redis, args)
      this.localCache = new LocalCache()