You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { Injectable } from '@nestjs/common';
import { RedisService as RedisInternalService, DEFAULT_REDIS_NAMESPACE } from '@liaoliaots/nestjs-redis';
import Redis from 'ioredis';
Module file:
import { Module, Global } from '@nestjs/common';
import { RedisModule } from '@liaoliaots/nestjs-redis';
import { ConfigService } from '@nestjs/config';
import { RedisConfig } from '../../config/config.interface';
import { ConfigKey } from '../../common/enum';
const modules = [
RedisModule.forRootAsync({
inject: [ConfigService],
useFactory: async (config: ConfigService) => {
const redisConfig = config.get(ConfigKey.LOGIN_REDIS);
console.log(redisConfig);
return {
readyLog: true,
errorLog: true,
config: {
}),
];
@global()
@module({
imports: modules,
exports: modules,
})
export class RedisConnectionModule {}
Service File:
import { Injectable } from '@nestjs/common';
import { RedisService as RedisInternalService, DEFAULT_REDIS_NAMESPACE } from '@liaoliaots/nestjs-redis';
import Redis from 'ioredis';
@Injectable()
export class RedisService {
private readonly cacheManager: Redis;
constructor(private readonly redisService: RedisInternalService) {
this.cacheManager = this.redisService.getClient(DEFAULT_REDIS_NAMESPACE);
}
// Currently creating a custom function but will replace once increment function available with mem cache
async incrementValue(key, expiry: number = 30 * 60): Promise {
const currentValue: string = await this.cacheManager.get(key);
const safeIntValue = currentValue === null ? 0 : parseInt(currentValue, 10);
await this.cacheManager.set(key, safeIntValue + 1, 'EX', expiry);
// await this.cacheManager.set('key', 'value', 'EX', expiry);
return safeIntValue + 1;
}
async setLoginToken(
token: string,
value,
expiry = 30 * 60 * 60 * 24,
): Promise {
return this.cacheManager.set(token, value, 'EX', expiry);
}
async getLoginToken(token: string): Promise {
return this.cacheManager.get(token);
}
}
Dependencies:
Redis server is AWS cluster and i am pointing to master node.
**Request goes to infinte loading.
Note: With simple redis setup with redis version 3.1.2 , things working fine.
Stuck with these problem from last few days. Need help on priority**
The text was updated successfully, but these errors were encountered: