Skip to content

Commit fa6d7e2

Browse files
authored
build(deps): bump lru-cache from 7.14.0 to 11.1.0 (#4302)
Signed-off-by: nikolay <[email protected]>
1 parent 50fb478 commit fa6d7e2

File tree

5 files changed

+21
-31
lines changed

5 files changed

+21
-31
lines changed

package-lock.json

Lines changed: 11 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/relay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"find-config": "^1.0.0",
6262
"json-bigint": "^1.0.0",
6363
"lodash": "^4.17.21",
64-
"lru-cache": "^7.14.0",
64+
"lru-cache": "^11.1.0",
6565
"pino": "^9.7.0",
6666
"redis": "^5.8.0"
6767
}

packages/relay/src/lib/clients/cache/localLRUCache.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// SPDX-License-Identifier: Apache-2.0
22

33
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
4-
import LRUCache, { LimitedByCount, LimitedByTTL } from 'lru-cache';
4+
import { LRUCache } from 'lru-cache';
55
import { Logger } from 'pino';
66
import { Gauge, Registry } from 'prom-client';
77

88
import { Utils } from '../../../utils';
99
import { ICacheClient } from './ICacheClient';
1010

11+
type LRUCacheOptions = LRUCache.OptionsMaxLimit<string, any, unknown> & LRUCache.OptionsTTLLimit<string, any, unknown>;
12+
1113
/**
1214
* Represents a LocalLRUCache instance that uses an LRU (Least Recently Used) caching strategy
1315
* for caching items internally from requests.
@@ -19,11 +21,13 @@ export class LocalLRUCache implements ICacheClient {
1921
*
2022
* @private
2123
*/
22-
private readonly options: LimitedByCount & LimitedByTTL = {
24+
private readonly options: LRUCacheOptions = {
2325
// The maximum number (or size) of items that remain in the cache (assuming no TTL pruning or explicit deletions).
2426
max: ConfigService.get('CACHE_MAX'),
2527
// Max time to live in ms, for items before they are considered stale.
2628
ttl: ConfigService.get('CACHE_TTL'),
29+
// Disable the preemptively removing stale items from the cache
30+
ttlAutopurge: false,
2731
};
2832

2933
/**

packages/ws-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"koa": "^2.13.4",
1515
"koa-cors": "^0.0.16",
1616
"koa-websocket": "^7.0.0",
17+
"lru-cache": "^11.1.0",
1718
"pino": "^9.7.0",
1819
"pino-pretty": "^7.6.1"
1920
},

packages/ws-server/src/service/subscriptionService.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'
44
import { generateRandomHex } from '@hashgraph/json-rpc-relay/dist/formatters';
55
import { Relay } from '@hashgraph/json-rpc-relay/dist/lib/relay';
66
import crypto from 'crypto';
7-
import LRU from 'lru-cache';
8-
import LRUCache from 'lru-cache';
7+
import { LRUCache } from 'lru-cache';
98
import { Logger } from 'pino';
109
import { Counter, Histogram, Registry } from 'prom-client';
1110

@@ -32,7 +31,7 @@ export class SubscriptionService {
3231
this.logger = logger;
3332
this.subscriptions = {};
3433

35-
this.cache = new LRU({ max: ConfigService.get('CACHE_MAX'), ttl: CACHE_TTL });
34+
this.cache = new LRUCache({ max: ConfigService.get('CACHE_MAX'), ttl: CACHE_TTL });
3635

3736
const activeSubscriptionHistogramName = 'rpc_websocket_subscription_times';
3837
register.removeSingleMetric(activeSubscriptionHistogramName);

0 commit comments

Comments
 (0)