Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 5474042

Browse files
committed
removed unused cache and constants
1 parent 5148e1a commit 5474042

File tree

2 files changed

+0
-79
lines changed

2 files changed

+0
-79
lines changed

src/helpers/cache/cacher.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import * as LRU from 'lru-cache';
22
import { Constants } from '../constants/constants';
33

44
const knexCache = new LRU(Constants.DEFAULT_CONNECTION_CACHE_OPTIONS);
5-
const tunnelCache = new LRU(Constants.DEFAULT_TUNNEL_CACHE_OPTIONS);
6-
const driverCache = new LRU(Constants.DEFAULT_DRIVER_CACHE_OPTIONS);
75

86
export class Cacher {
97
public static getCachedKnex(connectionConfig): any {
@@ -15,32 +13,6 @@ export class Cacher {
1513
knexCache.set(JSON.stringify(connectionConfig), newKnex);
1614
}
1715

18-
public static getTunnelCache(connection): any {
19-
const cachedTnl = tunnelCache.get(JSON.stringify(connection));
20-
return cachedTnl ? cachedTnl : null;
21-
}
22-
23-
public static setTunnelCache(connection, tnlObj): void {
24-
tunnelCache.set(JSON.stringify(connection), tnlObj);
25-
}
26-
27-
public static delTunnelCache(connection, tnlObj): void {
28-
tunnelCache.del(JSON.stringify(connection), tnlObj);
29-
}
30-
31-
public static getDriverCache(connection): any {
32-
const cachedDriver = driverCache.get(JSON.stringify(connection));
33-
return cachedDriver ? cachedDriver : null;
34-
}
35-
36-
public static setDriverCache(connection, newDriver): void {
37-
driverCache.set(JSON.stringify(connection), newDriver);
38-
}
39-
40-
public static delDriverCache(connection): void {
41-
driverCache.del(JSON.stringify(connection));
42-
}
43-
4416
public static async clearKnexCache() {
4517
if (process.env.NODE_ENV !== 'test') {
4618
console.error('Method clearKnexCache only for testing!');

src/helpers/constants/constants.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
export const Constants = {
2-
FORBIDDEN_HOSTS: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.0/8', 'fd00::/8'],
3-
42
DEFAULT_PAGINATION: { page: 1, perPage: 20 },
53
DEFAULT_LOGS_DIRNAME: 'logs',
64
DEFAULT_LOGS_FILENAME: 'autoadmin-logs.txt',
7-
KEEP_ALIVE_INTERVAL: 30000,
8-
KEEP_ALIVE_COUNT_MAX: 120,
95
DEFAULT_CONNECTION_CACHE_OPTIONS: {
106
max: 50,
117
length: function (n, key) {
@@ -16,53 +12,6 @@ export const Constants = {
1612
},
1713
maxAge: 1000 * 60 * 60,
1814
},
19-
20-
DEFAULT_TUNNEL_CACHE_OPTIONS: {
21-
max: 10000,
22-
length: function (n, key) {
23-
return n * 2 + key.length;
24-
},
25-
dispose: async function (key, n) {
26-
await n.knex.destroy();
27-
await n.tnl.close();
28-
},
29-
maxAge: 1000 * 60 * 60,
30-
},
31-
32-
DEFAULT_DRIVER_CACHE_OPTIONS: {
33-
max: 50,
34-
length: function (n, key) {
35-
return n * 2 + key.length;
36-
},
37-
dispose: function (key, n) {
38-
return 1;
39-
},
40-
maxAge: 1000 * 60 * 60,
41-
},
42-
43-
DEFAULT_SETTINGS_CACHE_OPTIONS: {
44-
max: 1000,
45-
length: function (n, key) {
46-
return n * 2 + key.length;
47-
},
48-
dispose: function (key, n) {
49-
return 1;
50-
},
51-
maxAge: 1000 * 60 * 60,
52-
},
53-
54-
DEFAULT_CONNECTIONS_CACHE_OPTIONS: {
55-
max: 1000,
56-
length: function (n, key) {
57-
return n * 2 + key.length;
58-
},
59-
dispose: function (key, n) {
60-
return 1;
61-
},
62-
maxAge: 1000 * 60 * 60,
63-
},
64-
65-
DEFAULT_FORWARD_IN_HOST: '127.0.0.1',
6615
AUTOCOMPLETE_ROW_LIMIT: 20,
6716
CLI_ATTEMPTS_COUNT: 3,
6817
CLI_QUIT_COMMAND: '$quit',

0 commit comments

Comments
 (0)