-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(instructions): implement instructions
- Loading branch information
1 parent
43f2422
commit fa31bbc
Showing
4 changed files
with
67 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict' | ||
|
||
/* | ||
* adonis-redis | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const path = require('path') | ||
|
||
module.exports = async function (cli) { | ||
try { | ||
await cli.copy( | ||
path.join(__dirname, './examples/redis.js'), | ||
path.join(cli.helpers.configPath(), 'redis.js') | ||
) | ||
cli.command.completed('create', 'config/redis.js') | ||
} catch (error) { | ||
// ignore error when redis.js already exists | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## Registering provider | ||
|
||
Make sure you register the provider inside `start/app.js` file before making use redis. | ||
|
||
```js | ||
const providers = [ | ||
'@adonisjs/redis/providers/RedisProvider' | ||
] | ||
``` | ||
|
||
Once that done you can make use of Redis anywhere by importing the redis provider. | ||
|
||
```js | ||
const Redis = use('Redis') | ||
await Redis.get() | ||
``` | ||
|
||
## Pub Sub | ||
In order to make use of pub/sub you can create `start/redis.js` file and subscribe to channels. | ||
|
||
```js | ||
const Redis = use('Redis') | ||
Redis.subscribe('news', async () => { | ||
}) | ||
|
||
// or bind listeners from `app/Listeners` directory | ||
Redis.subcribe('news', 'News.onMessage') | ||
``` | ||
|
||
## Config | ||
The config file `start/redis.js` contains all the configuration. Feel free to tweak it as per your needs. | ||
|
||
## Environment variables | ||
The configuration file makes use of **Environment variables**, make sure to define them for development and in production too | ||
|
||
``` | ||
REDIS_CONNECTION=local | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters