feat(medusa): add redis_prefix in configModule.projectConfig (#4268)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(medusa): add ability to prefix all redis cache keys in project config
|
||||||
@@ -41,7 +41,10 @@ export default async ({ app, configModule }: Options): Promise<Express> => {
|
|||||||
if (configModule?.projectConfig?.redis_url) {
|
if (configModule?.projectConfig?.redis_url) {
|
||||||
const RedisStore = createStore(session)
|
const RedisStore = createStore(session)
|
||||||
const redisClient = redis.createClient(configModule.projectConfig.redis_url)
|
const redisClient = redis.createClient(configModule.projectConfig.redis_url)
|
||||||
sessionOpts.store = new RedisStore({ client: redisClient })
|
sessionOpts.store = new RedisStore({
|
||||||
|
client: redisClient,
|
||||||
|
prefix: `${configModule?.projectConfig?.redis_prefix ?? ""}sess:`,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
app.set("trust proxy", 1)
|
app.set("trust proxy", 1)
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ export default class JobSchedulerService {
|
|||||||
this.config_ = config
|
this.config_ = config
|
||||||
this.logger_ = logger
|
this.logger_ = logger
|
||||||
|
|
||||||
|
const prefix = `${config?.projectConfig?.redis_prefix ?? ""}${
|
||||||
|
this.constructor.name
|
||||||
|
}`
|
||||||
|
|
||||||
if (singleton && config?.projectConfig?.redis_url) {
|
if (singleton && config?.projectConfig?.redis_url) {
|
||||||
// Required config
|
// Required config
|
||||||
// See: https://github.com/OptimalBits/bull/blob/develop/CHANGELOG.md#breaking-changes
|
// See: https://github.com/OptimalBits/bull/blob/develop/CHANGELOG.md#breaking-changes
|
||||||
@@ -40,13 +44,13 @@ export default class JobSchedulerService {
|
|||||||
|
|
||||||
this.queue_ = new Queue(`scheduled-jobs:queue`, {
|
this.queue_ = new Queue(`scheduled-jobs:queue`, {
|
||||||
connection,
|
connection,
|
||||||
prefix: `${this.constructor.name}`,
|
prefix,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Register scheduled job worker
|
// Register scheduled job worker
|
||||||
new Worker("scheduled-jobs:queue", this.scheduledJobsWorker, {
|
new Worker("scheduled-jobs:queue", this.scheduledJobsWorker, {
|
||||||
connection,
|
connection,
|
||||||
prefix: `${this.constructor.name}`,
|
prefix,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export type HttpCompressionOptions = {
|
|||||||
|
|
||||||
export type ProjectConfigOptions = {
|
export type ProjectConfigOptions = {
|
||||||
redis_url?: string
|
redis_url?: string
|
||||||
|
redis_prefix?: string
|
||||||
redis_options?: RedisOptions
|
redis_options?: RedisOptions
|
||||||
|
|
||||||
session_options?: SessionOptions
|
session_options?: SessionOptions
|
||||||
|
|||||||
Reference in New Issue
Block a user