feat(medusa): add redis_prefix in configModule.projectConfig (#4268)
This commit is contained in:
5
.changeset/shy-tools-cheat.md
Normal file
5
.changeset/shy-tools-cheat.md
Normal file
@@ -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) {
|
||||
const RedisStore = createStore(session)
|
||||
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)
|
||||
|
||||
@@ -30,6 +30,10 @@ export default class JobSchedulerService {
|
||||
this.config_ = config
|
||||
this.logger_ = logger
|
||||
|
||||
const prefix = `${config?.projectConfig?.redis_prefix ?? ""}${
|
||||
this.constructor.name
|
||||
}`
|
||||
|
||||
if (singleton && config?.projectConfig?.redis_url) {
|
||||
// Required config
|
||||
// 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`, {
|
||||
connection,
|
||||
prefix: `${this.constructor.name}`,
|
||||
prefix,
|
||||
})
|
||||
|
||||
// Register scheduled job worker
|
||||
new Worker("scheduled-jobs:queue", this.scheduledJobsWorker, {
|
||||
connection,
|
||||
prefix: `${this.constructor.name}`,
|
||||
prefix,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ export type HttpCompressionOptions = {
|
||||
|
||||
export type ProjectConfigOptions = {
|
||||
redis_url?: string
|
||||
redis_prefix?: string
|
||||
redis_options?: RedisOptions
|
||||
|
||||
session_options?: SessionOptions
|
||||
@@ -35,7 +36,7 @@ export type ProjectConfigOptions = {
|
||||
database_schema?: string
|
||||
database_logging: LoggerOptions
|
||||
|
||||
// @deprecated - only postgres is supported, so this config has no effect
|
||||
// @deprecated - only postgres is supported, so this config has no effect
|
||||
database_type?: string
|
||||
|
||||
http_compression?: HttpCompressionOptions
|
||||
|
||||
Reference in New Issue
Block a user