3.0.0 • Published 10 months ago

@tadashi/connect-redis v3.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 months ago

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:

connect([opts])

Connects to a Redis server or cluster.

singleton([opts])

Connects to a Redis instance or cluster as a singleton.

parametertyperequireddefaultdescription
optsObjectnosee belowSee configuration options

opts

parametertyperequireddefaultdescription
addressString|String[]no127.0.0.1:6379The address or addresses of the Redis server(s).
passwordStringno-The password for authenticating with the Redis server, if required.
clusterOptionsObjectno-See configuration options

Cluster

To use Cluster, set addresses separated by commas or an array and set clusterOptions.

import {connect} from '@tadashi/connect-redis'

const redis = connect({
  address: '127.0.0.1:6379, 127.0.0.1:6380, 127.0.0.1:6381',
  // or
  address: ['127.0.0.1:6379', '127.0.0.1:6380', '127.0.0.1:6381'],
  // and
  clusterOptions: {
    retryDelayOnClusterDown: 500,
    // ...
  }
})

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

Buy Me a Coffee

BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4

License

MIT © Thiago Lagden

3.0.0

10 months ago

2.3.0

2 years ago

2.4.0

2 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago