How to use redis-fast-driver - 7 common examples

To help you get started, we’ve selected a few redis-fast-driver 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 kevoj / nodetomic-api-swagger / src / lib / redis / pubsub.js View on Github external
/*
* Basic Example Pubsub
* Listener all nodes
*/

r.rawCall([
  'subscribe', `news`
], async function (e, data) {

  if (config.log)
    console.log(chalk.blueBright(`${data} - node = ${config.node}`));
});

// Send publish from node 0
if (config.node === 0) {
  const r2 = new Redis(config.redis.sessions.conn);
  setTimeout(function () {
    r2.rawCall(['PUBLISH', 'news', 'hello world!']);
  }, 3000);
}



// Thread event manager (Expired, del)
/*
if (node === 0) {
  r.rawCall([
    'subscribe', `__keyevent@${config.redis.sessions.conn.db}__:del`, `__keyevent@${config.redis.sessions.conn.db}__:expired`
  ], async function (e, data) {

    let obj = get(data);
    let msg = '';
github kevoj / nodetomic-api-swagger / src / lib / redis / ru.js View on Github external
import Redis from 'redis-fast-driver';
import config from '../../config';

const r = new Redis(config.redis.ru);
require('./status').default(r, config.redis.ru, 'ru');

// Create
export async function create(key, value) {
  try {
    let id = key.split(':')[0];
    await r.rawCall(['SET', id, value]);
  } catch (err) {
    throw `Error 1i Redis ${err}`;
  }
  return true;
}

// Get by key
export function get(key) {
  return new Promise((resolve, reject) => {
github kevoj / nodetomic-api-swagger / src / lib / redis / rs.js View on Github external
import Redis from 'redis-fast-driver';
import config from '../../config';

const r = new Redis(config.redis.rs);
require('./status').default(r, config.redis.rs, 'rs');

// Create
export async function create(key, value, ttl) {
  try {
    let id = key.split(':')[0];
    if (!config.redis.multiple)
      await destroyMultiple(id);
    if (ttl) {
      await r.rawCall(['SETEX', key, ttl, value]);
    } else {
      await r.rawCall(['SET', key, value]);
    }
  } catch (err) {
    throw `Error 1 Redis ${err}`;
  }
github kevoj / nodetomic-api-swagger / src / lib / redis / pubsub.js View on Github external
import Redis from 'redis-fast-driver';
import chalk from 'chalk';
import config from '../../config';

const r = new Redis(config.redis.sessions.conn);
require('./status').default(r, config.redis.sessions.conn, 'pubsub');

/*
* Basic Example Pubsub
* Listener all nodes
*/

r.rawCall([
  'subscribe', `news`
], async function (e, data) {

  if (config.log)
    console.log(chalk.blueBright(`${data} - node = ${config.node}`));
});

// Send publish from node 0
github kevoj / redis-jwt / src / index.js View on Github external
constructor(config) {
        this.config = config;
        this.r = new Redis(this.config);

        let self = this;
        setTimeout(() => {
            self.ping().then(result => {
                if (!result) {
                    console.log(chalk.redBright(`redis-jwt-> Could not establish a connection`));
                    throw 'Error';
                }
            });
        }, 2000);
    }
github kevoj / redis-jwt / lib / index.js View on Github external
constructor(config) {
        this.config = config;
        this.r = new Redis(this.config);
        this.events();
    }
github kevoj / nodetomic-api-swagger / src / lib / redis / index.js View on Github external
import Redis from 'redis-fast-driver';
import config from '../../config';

const r = new Redis({
  //host: '/tmp/redis.sock', //unix domain
  host: '127.0.0.1', //can be IP or hostname
  port: 6379,
  maxretries: 10, //reconnect retries, default 10
  //auth: '123', //optional password, if needed
  //db: 5, //optional db selection
});

require('./status').default(r, config.redis.token.uri);

//Create / update

export async function create(key, data, ttl) {

  try {
    if (!config.redis.token.multiple)

redis-fast-driver

Fast truly async driver for redis (based on hiredis async version)

MIT
Latest version published 8 months ago

Package Health Score

56 / 100
Full package analysis

Popular redis-fast-driver functions