1- # fastify- redis
1+ # @ fastify/ redis
22
33![ 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 )
55[ ![ Known Vulnerabilities] ( https://snyk.io/test/github/fastify/fastify-redis/badge.svg )] ( https://snyk.io/test/github/fastify/fastify-redis )
66[ ![ js-standard-style] ( https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat )] ( https://standardjs.com/ )
77
@@ -10,7 +10,7 @@ Fastify Redis connection plugin; with this you can share the same Redis connecti
1010## Install
1111
1212```
13- npm i fastify- redis --save
13+ npm i @ fastify/ redis --save
1414```
1515
1616## Usage
@@ -25,13 +25,13 @@ Under the hood [ioredis](https://github.com/luin/ioredis) is used as client, the
2525const fastify = require (' fastify' )()
2626
2727// 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' })
2929
3030// 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 */ })
3232
3333// OR with more options
34- fastify .register (require (' fastify- redis' ), {
34+ fastify .register (require (' @ fastify/ redis' ), {
3535 host: ' 127.0.0.1' ,
3636 password: ' ***' ,
3737 port: 6379 , // Redis port
@@ -49,7 +49,7 @@ The client is automatically closed when the fastify instance is closed.
4949' use strict'
5050
5151const Fastify = require (' fastify' )
52- const fastifyRedis = require (' fastify- redis' )
52+ const fastifyRedis = require (' @ fastify/ redis' )
5353
5454const fastify = Fastify ({ logger: true })
5555
@@ -93,15 +93,15 @@ closed.
9393const fastify = require (' fastify' )()
9494const redis = require (' redis' ).createClient ({ host: ' localhost' , port: 6379 })
9595
96- fastify .register (require (' fastify- redis' ), { client: redis })
96+ fastify .register (require (' @ fastify/ redis' ), { client: redis })
9797```
9898
99- Note: by default, * fastify- redis* will ** not** automatically close the client
99+ Note: by default, * @ fastify/ redis * will ** not** automatically close the client
100100connection when the Fastify server shuts down. To opt-in to this behavior,
101101register the client like so:
102102
103103``` js
104- fastify .register (require (' fastify- redis' ), {
104+ fastify .register (require (' @ fastify/ redis' ), {
105105 client: redis,
106106 closeClient: true
107107})
@@ -118,12 +118,12 @@ const fastify = require('fastify')()
118118const redis = require (' redis' ).createClient ({ host: ' localhost' , port: 6379 })
119119
120120fastify
121- .register (require (' fastify- redis' ), {
121+ .register (require (' @ fastify/ redis' ), {
122122 host: ' 127.0.0.1' ,
123123 port: 6380 ,
124124 namespace: ' hello'
125125 })
126- .register (require (' fastify- redis' ), {
126+ .register (require (' @ fastify/ redis' ), {
127127 client: redis,
128128 namespace: ' world'
129129 })
@@ -173,14 +173,14 @@ fastify.listen(3000, function (err) {
173173
174174## Redis streams (Redis 5.0 or greater is required)
175175
176- ` fastify- redis ` supports Redis streams out of the box.
176+ ` @ fastify/ redis` supports Redis streams out of the box.
177177
178178``` js
179179' use strict'
180180
181181const fastify = require (' fastify' )()
182182
183- fastify .register (require (' fastify- redis' ), {
183+ fastify .register (require (' @ fastify/ redis' ), {
184184 host: ' 127.0.0.1' ,
185185 port: 6380
186186})
0 commit comments