Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 28 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Injectable } from '@nestjs/common'; |
||
2 | import { ICacheRBAC } from '../interfaces/cache.rbac.interface'; |
||
3 | import * as NodeCache from 'node-cache'; |
||
4 | |||
5 | @Injectable() |
||
6 | export class RbacCache implements ICacheRBAC { |
||
7 | KEY = 'RBAC'; |
||
8 | TTL = 0; |
||
9 | |||
10 | private readonly cache; |
||
11 | |||
12 | constructor() { |
||
13 | this.cache = new NodeCache(); |
||
14 | } |
||
15 | |||
16 | get(): object | null { |
||
17 | return this.cache.get(this.KEY); |
||
18 | } |
||
19 | |||
20 | set(value: object): void { |
||
21 | this.cache.set(this.KEY, value, this.TTL); |
||
22 | } |
||
23 | |||
24 | del(): void { |
||
25 | this.cache.del(this.KEY); |
||
26 | } |
||
27 | } |
||
28 |