src/cache/rbac.cache.ts   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 28
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 22
mnd 0
bc 0
fnc 3
dl 0
loc 28
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A RbacCache.get 0 3 1
A RbacCache.set 0 3 1
A RbacCache.del 0 3 1
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