@tadashi/connect-redis
v2.4.0
Published
Simplifying Redis connection
Downloads
38
Readme
connect-redis
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