mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-15 04:59:42 +03:00
Working Redis
This commit is contained in:
@@ -9,11 +9,14 @@ export const RedisOptions: CacheModuleAsyncOptions = {
|
|||||||
socket: {
|
socket: {
|
||||||
host: config.redis.redis_host,
|
host: config.redis.redis_host,
|
||||||
port: config.redis.redis_port,
|
port: config.redis.redis_port,
|
||||||
passphrase: config.redis.redis_password,
|
|
||||||
},
|
},
|
||||||
|
database: config.redis.redis_database,
|
||||||
|
password: config.redis.redis_password,
|
||||||
|
ttl: 30,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
store: () => store,
|
store: () => store,
|
||||||
|
isGlobal: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Controller, Get, Param } from '@nestjs/common';
|
import { CacheInterceptor, CacheKey, CacheTTL } from '@nestjs/cache-manager';
|
||||||
|
import { Controller, Get, Param, UseInterceptors } from '@nestjs/common';
|
||||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { AdminService } from './admin.service';
|
import { AdminService } from './admin.service';
|
||||||
|
|
||||||
@@ -10,6 +11,9 @@ export class AdminController {
|
|||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
description: 'Get admins from db',
|
description: 'Get admins from db',
|
||||||
})
|
})
|
||||||
|
@CacheKey('admins')
|
||||||
|
@CacheTTL({ ttl: 5 } as any)
|
||||||
|
@UseInterceptors(CacheInterceptor)
|
||||||
@Get('get')
|
@Get('get')
|
||||||
async getAdmin() {
|
async getAdmin() {
|
||||||
return await this.adminService.getAdmins();
|
return await this.adminService.getAdmins();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { Injectable, Logger } from '@nestjs/common';
|
|||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Admin } from 'libs/database/admin.entity';
|
import { Admin } from 'libs/database/admin.entity';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminService {
|
export class AdminService {
|
||||||
private readonly logger: Logger = new Logger(AdminService.name);
|
private readonly logger: Logger = new Logger(AdminService.name);
|
||||||
@@ -18,7 +17,7 @@ export class AdminService {
|
|||||||
}));
|
}));
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.log(`[getAdmin] ${JSON.stringify({ error })}`);
|
this.logger.log(`[getAdmin] ${error}`);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user