Skip to content

Commit

Permalink
BC-6040 Upgrade Redis (#4762)
Browse files Browse the repository at this point in the history
* Remove unused const regarding redis

* Upgrade packages

* Remove unused connect-redis package

* Register error event handler before connecting
  • Loading branch information
dyedwiper authored and mkreuzkam-cap committed Feb 21, 2024
1 parent b3b0702 commit 93e15be
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 218 deletions.
9 changes: 4 additions & 5 deletions apps/server/src/infra/cache/cache.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { CacheModule, CacheModuleOptions } from '@nestjs/cache-manager';
import { Module } from '@nestjs/common';
import { LegacyLogger, LoggerModule } from '@src/core/logger';
import { create } from 'cache-manager-redis-store';
import { RedisClient } from 'redis';
import { redisStore } from 'cache-manager-redis-yet';
import { CacheStoreType } from './interface';
import { CacheService } from './service/cache.service';

@Module({
imports: [
CacheModule.registerAsync({
useFactory: (cacheService: CacheService, logger: LegacyLogger): CacheModuleOptions => {
useFactory: async (cacheService: CacheService, logger: LegacyLogger): Promise<CacheModuleOptions> => {
if (cacheService.getStoreType() === CacheStoreType.REDIS) {
const redisUrl: string = Configuration.get('REDIS_URI') as string;
const store = create({ url: redisUrl });
const client: RedisClient = store.getClient();
const store = await redisStore({ url: redisUrl });
const { client } = store;

client.on('error', (error) => logger.error(error));
client.on('connect', (msg) => logger.log(msg));
Expand Down
1 change: 0 additions & 1 deletion apps/server/src/infra/redis/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/server/src/infra/redis/interface/redis.constants.ts

This file was deleted.

Loading

0 comments on commit 93e15be

Please sign in to comment.