Skip to content

lagden/connect-redis

Repository files navigation

connect-redis

NPM version Node.js CI Coverage Status Snyk badge

Simplifying Redis connection

Install

$ npm i -S @tadashi/connect-redis

API

There are two ways to connect:

  • singleton.connect(\[opts\])
  • connect(\[opts\])
Name Type Default Description
opts object {address: '127.0.0.1:6379'} See configuration options - ioredis

Obs.:

opts.address Addresses to connect (separated by commas or array)

Cluster

To use Cluster, set addresses separated by commas or array:

const redis = connect({
  address: '127.0.0.1:6379,127.0.0.1:6380,127.0.0.1:6381'
})

// or

const redis = connect({
  address: ['127.0.0.1:6379', '127.0.0.1:6380', '127.0.0.1:6381']
})

Usage

import connect from '@tadashi/connect-redis'

const redis = connect()

await redis.set('a', 'xxx')
const result = await redis.get('a')

console.log(result) // => xxx

License

MIT © Thiago Lagden