fix(core): own cache transports and accept cleanup reviews
This commit is contained in:
parent
bd9332b2f6
commit
b4ac6460ef
24 changed files with 504 additions and 97 deletions
|
|
@ -7,6 +7,13 @@ export function registerCacheServices(
|
|||
config: AppConfig
|
||||
): void {
|
||||
if (config.redis?.enabled) {
|
||||
if (config.redis.keyPrefix !== undefined) {
|
||||
container
|
||||
.resolve('logger')
|
||||
.warn(
|
||||
'Redis keyPrefix is deprecated at the DI boundary; service/global/proxy namespaces remain fixed'
|
||||
);
|
||||
}
|
||||
container.register({
|
||||
cache: asFunction(({ logger }) => {
|
||||
const { createServiceCache } = require('@stock-bot/queue');
|
||||
|
|
@ -21,11 +28,15 @@ export function registerCacheServices(
|
|||
port: config.redis.port,
|
||||
password: config.redis.password,
|
||||
username: config.redis.username,
|
||||
maxRetriesPerRequest: config.redis.maxRetries,
|
||||
retryDelay: config.redis.retryDelay,
|
||||
db: config.redis.db, // This will be overridden by ServiceCache
|
||||
},
|
||||
{ logger }
|
||||
{ logger, shared: false, ttl: config.redis.ttl }
|
||||
);
|
||||
}).singleton(),
|
||||
})
|
||||
.singleton()
|
||||
.disposer(cache => cache.disconnect()),
|
||||
|
||||
// Also provide global cache for shared data
|
||||
globalCache: asFunction(({ logger }) => {
|
||||
|
|
@ -39,10 +50,14 @@ export function registerCacheServices(
|
|||
port: config.redis.port,
|
||||
password: config.redis.password,
|
||||
username: config.redis.username,
|
||||
maxRetriesPerRequest: config.redis.maxRetries,
|
||||
retryDelay: config.redis.retryDelay,
|
||||
},
|
||||
{ global: true, logger }
|
||||
{ global: true, logger, shared: false, ttl: config.redis.ttl }
|
||||
);
|
||||
}).singleton(),
|
||||
})
|
||||
.singleton()
|
||||
.disposer(cache => cache.disconnect()),
|
||||
});
|
||||
} else {
|
||||
container.register({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue