diff --git a/lib/cache/in-memory.ts b/lib/cache/in-memory.ts index 3530a0466a5..6be7224dcf3 100644 --- a/lib/cache/in-memory.ts +++ b/lib/cache/in-memory.ts @@ -22,7 +22,7 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import LRU from 'lru-cache'; +import {LRUCache} from 'lru-cache'; import type {GetResult} from '../../types/cache.interfaces.js'; @@ -30,12 +30,12 @@ import {BaseCache} from './base.js'; export class InMemoryCache extends BaseCache { readonly cacheMb: number; - private readonly cache: LRU; + private readonly cache: LRUCache; constructor(cacheName: string, cacheMb: number) { super(cacheName, `InMemoryCache(${cacheMb}Mb)`, 'memory'); this.cacheMb = cacheMb; - this.cache = new LRU({ + this.cache = new LRUCache({ maxSize: cacheMb * 1024 * 1024, sizeCalculation: n => n.length, }); diff --git a/lib/cache/on-disk.ts b/lib/cache/on-disk.ts index d43475f2fee..537bccb9331 100644 --- a/lib/cache/on-disk.ts +++ b/lib/cache/on-disk.ts @@ -25,7 +25,7 @@ import path from 'path'; import fs from 'fs-extra'; -import LRU from 'lru-cache'; +import {LRUCache} from 'lru-cache'; import type {GetResult} from '../../types/cache.interfaces.js'; import {logger} from '../logger.js'; @@ -48,13 +48,13 @@ type CacheEntry = {path: string; size: number}; export class OnDiskCache extends BaseCache { readonly path: string; readonly cacheMb: number; - private readonly cache: LRU; + private readonly cache: LRUCache; constructor(cacheName: string, path: string, cacheMb: number) { super(cacheName, `OnDiskCache(${path}, ${cacheMb}mb)`, 'disk'); this.path = path; this.cacheMb = cacheMb; - this.cache = new LRU({ + this.cache = new LRUCache({ maxSize: cacheMb * 1024 * 1024, sizeCalculation: n => n.size, noDisposeOnSet: true, diff --git a/package-lock.json b/package-lock.json index e4eef97c5c1..9ee57434163 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "jszip": "^3.7.1", "lodash": "^4.17.21", "lodash.clonedeep": "^4.5.0", - "lru-cache": "^8.0.3", + "lru-cache": "^9.1.2", "lz-string": "^1.4.4", "monaco-editor": "^0.36.1", "monaco-vim": "^0.3.5", @@ -14242,11 +14242,11 @@ "integrity": "sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==" }, "node_modules/lru-cache": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz", - "integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-9.1.2.tgz", + "integrity": "sha512-ERJq3FOzJTxBbFjZ7iDs+NiK4VI9Wz+RdrrAB8dio1oV+YvdPzUEE4QNiT2VD51DkIbCYRUUzCRkssXCHqSnKQ==", "engines": { - "node": ">=16.14" + "node": "14 || >=16.14" } }, "node_modules/lz-string": { diff --git a/package.json b/package.json index d731140201e..952c591f530 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "jszip": "^3.7.1", "lodash": "^4.17.21", "lodash.clonedeep": "^4.5.0", - "lru-cache": "^8.0.3", + "lru-cache": "^9.1.2", "lz-string": "^1.4.4", "monaco-editor": "^0.36.1", "monaco-vim": "^0.3.5", diff --git a/static/compiler-service.ts b/static/compiler-service.ts index 514c4d86a27..f3086c611a3 100644 --- a/static/compiler-service.ts +++ b/static/compiler-service.ts @@ -25,7 +25,7 @@ import $ from 'jquery'; import * as Sentry from '@sentry/browser'; import _ from 'underscore'; -import LRU from 'lru-cache'; +import {LRUCache} from 'lru-cache'; import {EventEmitter} from 'golden-layout'; import {options} from './options.js'; @@ -44,12 +44,12 @@ const ASCII_COLORS_RE = new RegExp(/\x1B\[[\d;]*m(.\[K)?/g); export class CompilerService { private readonly base = window.httpRoot; private allowStoreCodeDebug: boolean; - cache: LRU; + cache: LRUCache; private readonly compilersByLang: Record>; constructor(eventHub: EventEmitter) { this.allowStoreCodeDebug = true; - this.cache = new LRU({ + this.cache = new LRUCache({ maxSize: 200 * 1024, sizeCalculation: n => JSON.stringify(n).length, }); diff --git a/static/panes/compiler.ts b/static/panes/compiler.ts index de1049f7fbc..f218017e849 100644 --- a/static/panes/compiler.ts +++ b/static/panes/compiler.ts @@ -29,7 +29,7 @@ import {ga} from '../analytics.js'; import * as colour from '../colour.js'; import {Toggles} from '../widgets/toggles.js'; import * as Components from '../components.js'; -import LruCache from 'lru-cache'; +import {LRUCache} from 'lru-cache'; import {options} from '../options.js'; import * as monaco from 'monaco-editor'; import {Alert} from '../widgets/alert.js'; @@ -79,7 +79,7 @@ type CachedOpcode = { found: boolean; data: AssemblyInstructionInfo | string; }; -const OpcodeCache = new LruCache({ +const OpcodeCache = new LRUCache({ maxSize: 64 * 1024, sizeCalculation: function (n) { return JSON.stringify(n).length;