1
- # fastify- redis
1
+ # @ fastify/ redis
2
2
3
3
![ CI] ( https://github.com/fastify/fastify-redis/workflows/CI/badge.svg )
4
- [ ![ NPM version] ( https://img.shields.io/npm/v/fastify- redis.svg?style=flat )] ( https://www.npmjs.com/package/fastify- redis )
4
+ [ ![ NPM version] ( https://img.shields.io/npm/v/@ fastify/ redis.svg?style=flat )] ( https://www.npmjs.com/package/@ fastify/ redis )
5
5
[ ![ Known Vulnerabilities] ( https://snyk.io/test/github/fastify/fastify-redis/badge.svg )] ( https://snyk.io/test/github/fastify/fastify-redis )
6
6
[ ![ js-standard-style] ( https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat )] ( https://standardjs.com/ )
7
7
@@ -10,7 +10,7 @@ Fastify Redis connection plugin; with this you can share the same Redis connecti
10
10
## Install
11
11
12
12
```
13
- npm i fastify- redis --save
13
+ npm i @ fastify/ redis --save
14
14
```
15
15
16
16
## Usage
@@ -25,13 +25,13 @@ Under the hood [ioredis](https://github.com/luin/ioredis) is used as client, the
25
25
const fastify = require (' fastify' )()
26
26
27
27
// create by specifying host
28
- fastify .register (require (' fastify- redis' ), { host: ' 127.0.0.1' })
28
+ fastify .register (require (' @ fastify/ redis' ), { host: ' 127.0.0.1' })
29
29
30
30
// OR by specifying Redis URL
31
- fastify .register (require (' fastify- redis' ), { url: ' redis://127.0.0.1' , /* other redis options */ })
31
+ fastify .register (require (' @ fastify/ redis' ), { url: ' redis://127.0.0.1' , /* other redis options */ })
32
32
33
33
// OR with more options
34
- fastify .register (require (' fastify- redis' ), {
34
+ fastify .register (require (' @ fastify/ redis' ), {
35
35
host: ' 127.0.0.1' ,
36
36
password: ' ***' ,
37
37
port: 6379 , // Redis port
@@ -49,7 +49,7 @@ The client is automatically closed when the fastify instance is closed.
49
49
' use strict'
50
50
51
51
const Fastify = require (' fastify' )
52
- const fastifyRedis = require (' fastify- redis' )
52
+ const fastifyRedis = require (' @ fastify/ redis' )
53
53
54
54
const fastify = Fastify ({ logger: true })
55
55
@@ -93,15 +93,15 @@ closed.
93
93
const fastify = require (' fastify' )()
94
94
const redis = require (' redis' ).createClient ({ host: ' localhost' , port: 6379 })
95
95
96
- fastify .register (require (' fastify- redis' ), { client: redis })
96
+ fastify .register (require (' @ fastify/ redis' ), { client: redis })
97
97
```
98
98
99
- Note: by default, * fastify- redis* will ** not** automatically close the client
99
+ Note: by default, * @ fastify/ redis * will ** not** automatically close the client
100
100
connection when the Fastify server shuts down. To opt-in to this behavior,
101
101
register the client like so:
102
102
103
103
``` js
104
- fastify .register (require (' fastify- redis' ), {
104
+ fastify .register (require (' @ fastify/ redis' ), {
105
105
client: redis,
106
106
closeClient: true
107
107
})
@@ -118,12 +118,12 @@ const fastify = require('fastify')()
118
118
const redis = require (' redis' ).createClient ({ host: ' localhost' , port: 6379 })
119
119
120
120
fastify
121
- .register (require (' fastify- redis' ), {
121
+ .register (require (' @ fastify/ redis' ), {
122
122
host: ' 127.0.0.1' ,
123
123
port: 6380 ,
124
124
namespace: ' hello'
125
125
})
126
- .register (require (' fastify- redis' ), {
126
+ .register (require (' @ fastify/ redis' ), {
127
127
client: redis,
128
128
namespace: ' world'
129
129
})
@@ -173,14 +173,14 @@ fastify.listen(3000, function (err) {
173
173
174
174
## Redis streams (Redis 5.0 or greater is required)
175
175
176
- ` fastify- redis ` supports Redis streams out of the box.
176
+ ` @ fastify/ redis` supports Redis streams out of the box.
177
177
178
178
``` js
179
179
' use strict'
180
180
181
181
const fastify = require (' fastify' )()
182
182
183
- fastify .register (require (' fastify- redis' ), {
183
+ fastify .register (require (' @ fastify/ redis' ), {
184
184
host: ' 127.0.0.1' ,
185
185
port: 6380
186
186
})
0 commit comments