Skip to content

Redis store for node-cache-manager using node_redis.

License

Notifications You must be signed in to change notification settings

FrancescBagur/node-cache-manager-redis-yet

Repository files navigation

Redis store for node cache manager

npm version codecov

Redis cache store for node-cache-manager.

Installation

pnpm install cache-manager-redis-yet

NestJs

Module

import { CacheModule as _CacheModule } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';

import { redisStore } from 'cache-manager-redis-yet';

@Module({
  imports: [
    _CacheModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: async (config: ConfigService) => {
        const conf = {
          url: config.get<string>('REDIS_URL'),
          ttl: config.get<number>('REDIS_CACHE_TTL'),
        };
        return {
          store: await redisStore(conf),
          ...conf,
        };
      },
    }),
  ],
})
export class CacheModule {}

Service

import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
import { RedisCache } from 'cache-manager-redis-yet';

@Injectable()
export class CacheService {
  constructor(@Inject(CACHE_MANAGER) private readonly cache: RedisCache) {}
}

License

Licensed under the MIT license.

Fork from https://github.com/dabroek/node-cache-manager-redis-store

About

Redis store for node-cache-manager using node_redis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published