You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

redis-adapter

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-adapter

Simple Redis Adapter

0.2.0
latest
Source
npmnpm
Version published
Weekly downloads
159
-45.36%
Maintainers
1
Weekly downloads
 
Created
Source

redis-adapter 🔌

This is simple Redis client adapter with promises.

Build Status

Methods and usage

  • Create connection
const Redis = require('redis-adapter');

const client = new Redis({port: 6379, host: '127.0.0.1'});

client.connect()
    .then(() => {
        console.log('Hooray!');
    })
    .catch(error => {
        console.log('Connection failed!');
    });

client.on('end', () => {
    console.log('Connection closed')
});
  • Connection with prefix
const client = new Redis({port: 6379, host: '127.0.0.1', prefix: 'prefix'});
  • Call methods
client.call('smembers', 'blocks').then(blocks => {
    console.log('List of blocks:', blocks);
});
  • Use shape for plain shapes:
client.shape({
    blocks: ['smembers', 'blocks'],
    hashName: ['hget', 'data', 'name'],
    range: ['zrange', 'logs', 0, '+inf'],
}).then(({blocks, hashName, range}) => {
    console.log('blocks set:', blocks);
    console.log('hash key "name" value:', hashName);
    console.log('range:', range);
});
  • Instant multi
client.multi([
    ['smembers', 'blocks'],
    ['hget', 'data', 'name'],
    ['zrange', 'logs', 0, '+inf'],
]).then(([blocks, hashName, range]) => {
    console.log('blocks set:', blocks);
    console.log('hash key "name" value:', hashName);
    console.log('range:', range);
});

Modify response

Methods:

  • map
  • filter
  • reduce
  • some
  • every
  • orderBy
  • sort
  • paginate
  • count
  • asc
  • desc
  • take
  • takeLast
  • reverse
  • json
client
    .call('smembers', 'items')
    .map(Number)
    .asc()
    .then(console.log);

client
    .call('zrangebyscore', 'somethings', '-inf', '+inf')
    .map(x => Number(x.property))
    .filter(p => p > 0)
    .desc()
    .then(console.log);

client
    .call('smembers')

FAQs

Package last updated on 29 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts