Rocketseat / adonis-bull

The easiest way to start using an asynchronous job queue with AdonisJS. Ready for Adonis v5 ⚡️
MIT License
310 stars 57 forks source link

Adonis v5 Key Prefix #98

Closed jericopulvera closed 2 years ago

jericopulvera commented 2 years ago

Redis Key Prefix is not documented somewhere in v5.

ebbbang commented 2 years ago

Just use the keyPrefix attribute of connection.

E.g.

import Env from '@ioc:Adonis/Core/Env'
import { BullConfig } from '@ioc:Rocketseat/Bull'
import Application from '@ioc:Adonis/Core/Application'

/*
|--------------------------------------------------------------------------
| Bull configuration
|--------------------------------------------------------------------------
|
| Following is the configuration used by the Bull provider to connect to
| the redis server.
|
| Do make sure to pre-define the connections type inside `contracts/bull.ts`
| file for Rocketseat/Bull to recognize connections.
|
| Make sure to check `contracts/bull.ts` file for defining extra connections
*/

const bullConfig: BullConfig = {
  connection: Env.get('BULL_CONNECTION', 'local'),

  connections: {
    local: {
      host: Env.get('BULL_REDIS_HOST', 'localhost'),
      port: Env.get('BULL_REDIS_PORT'),
      password: Env.get('BULL_REDIS_PASSWORD'),
      keyPrefix: Application.inProduction ? 'yourUniqueProjectPrefix-prod' : 'yourUniqueProjectPrefix-dev',
    },
  },
}

export default bullConfig
jericopulvera commented 2 years ago

keyPrefix will not work on v5 version more details here #116