adonis-redis
AdonisJs official redis provider to make working with redis fun and simple.
Last updated a year ago by adonisjs .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install adonis-redis 
SYNC missed versions from official npm registry.

AdonisJS Framework

Gitter Trello Version Build Status Coverage Status Downloads License

:pray: This is an official AdonisJs redis provider to make your life easier when working with Redis.

Redis provider makes it easier for you to work with redis and has out of the box support for Pub/Sub.

Installation

npm i --save adonis-redis

Setup

Once you have installed the provider from the npm, make sure to follow the below steps to setup the provider.

bootstrap/app.js
const providers = [
  ...,
  'adonis-redis/providers/RedisFactory',
  'adonis-redis/providers/Redis'
]

Redis Factory is a layer on top of IoRedis and Redis provider is something you are going to make use of. So setup an alias for that.

bootstrap/app.js
const aliases = {
  ...,
  Redis: 'Adonis/Addons/Redis'
}

Now you are free to make use of Redis anywhere in your application. Make sure to check official docs for same Redis Documentation.

Redis Config

You have to save the configuration for redis inside config/redis.js file. You can define multiple connections inside this file and specify the main connection under the connection property.

module.exports = {
  connection: 'redis',
  
  redis: {
    port: 6379,          // Redis port
    host: '127.0.0.1',   // Redis host
    family: 4,           // 4 (IPv4) or 6 (IPv6)
    password: 'auth',
    db: 0
  },
  
  redisAlternate: {
    port: 6380,          // Redis port
    host: '127.0.0.1',   // Redis host
    family: 4,           // 4 (IPv4) or 6 (IPv6)
    password: 'auth',
    db: 0
  }

}

Cluster Config

module.exports = {
  connection: 'redis',

  redis: {
    clusters: [
      {
        port: 6380,
        host: '127.0.0.1'
      },
      {
        port: 6381,
        host: '127.0.0.1'      
      }
    ],
    redisOptions: {}
  }
}
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 2
Last Day 0
Last Week 1
Last Month 7
Dependencies (6)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |