Skip to content

Commit

Permalink
Bump to latest LRUCache; use the correct import now the old way is de…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt authored Jun 7, 2023
1 parent 4187390 commit 3b75a22
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/cache/in-memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
// 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';

import {BaseCache} from './base.js';

export class InMemoryCache extends BaseCache {
readonly cacheMb: number;
private readonly cache: LRU<string, Buffer>;
private readonly cache: LRUCache<string, Buffer>;

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,
});
Expand Down
6 changes: 3 additions & 3 deletions lib/cache/on-disk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string, CacheEntry>;
private readonly cache: LRUCache<string, CacheEntry>;

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,
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions static/compiler-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string, CompilationResult>;
cache: LRUCache<string, CompilationResult>;
private readonly compilersByLang: Record<string, Record<string, CompilerInfo>>;

constructor(eventHub: EventEmitter) {
this.allowStoreCodeDebug = true;
this.cache = new LRU({
this.cache = new LRUCache({
maxSize: 200 * 1024,
sizeCalculation: n => JSON.stringify(n).length,
});
Expand Down
4 changes: 2 additions & 2 deletions static/panes/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -79,7 +79,7 @@ type CachedOpcode = {
found: boolean;
data: AssemblyInstructionInfo | string;
};
const OpcodeCache = new LruCache<string, CachedOpcode>({
const OpcodeCache = new LRUCache<string, CachedOpcode>({
maxSize: 64 * 1024,
sizeCalculation: function (n) {
return JSON.stringify(n).length;
Expand Down

0 comments on commit 3b75a22

Please sign in to comment.