From 1654aa46feb03aa4e44d9486a377c0c55a9582b0 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 28 Aug 2018 21:54:47 +0200 Subject: [PATCH] Re-add the LRU removal (higher-level) (#200) --- packages/db-diskdown/src/index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/db-diskdown/src/index.ts b/packages/db-diskdown/src/index.ts index d1fcdbb5d..1514cb087 100644 --- a/packages/db-diskdown/src/index.ts +++ b/packages/db-diskdown/src/index.ts @@ -5,13 +5,13 @@ import { DiskStore } from './types'; import { AbstractLevelDOWN } from 'abstract-leveldown'; -import { LRUMap } from 'lru_map'; +// import { LRUMap } from 'lru_map'; import isUndefined from '@polkadot/util/is/undefined'; import logger from '@polkadot/util/logger'; import Combined from './store/Combined'; -const LRU_SIZE = 16384; +// const LRU_SIZE = 16384; const KEY_LENGTH = 32; const l = logger('disk/scatter'); @@ -20,13 +20,13 @@ const noop = () => class DiskDown extends AbstractLevelDOWN { _disk: DiskStore; - _store: LRUMap; + // _store: LRUMap; constructor (location: string) { super(location); this._disk = new Combined(location); - this._store = new LRUMap(LRU_SIZE); + // this._store = new LRUMap(LRU_SIZE); } compact (progress: (message: string) => void): void { @@ -73,7 +73,7 @@ class DiskDown extends AbstractLevelDOWN { _del (key: Buffer, options: any, callback: Function) { l.debug(() => ['_del', key]); - this._store.delete(key.toString()); + // this._store.delete(key.toString()); this._disk.delete(key); process.nextTick(callback); @@ -82,7 +82,10 @@ class DiskDown extends AbstractLevelDOWN { _get (key: Buffer, options: any, callback: Function) { l.debug(() => ['_get', key.toString('hex')]); - const value = this._store.get(key.toString()) || this._disk.get(key); + // FIXME _If_ LRU is re-instated, it needs to get set once a value is + // retrieved from disk. (As of now, not needed since removed) + // const value = this._store.get(key.toString()) || this._disk.get(key); + const value = this._disk.get(key); if (isUndefined(value)) { process.nextTick(callback, new Error('NotFound')); @@ -95,7 +98,7 @@ class DiskDown extends AbstractLevelDOWN { _put (key: Buffer, value: Buffer, options: any, callback: Function) { l.debug(() => ['_put', key.toString('hex'), value]); - this._store.set(key.toString(), value); + // this._store.set(key.toString(), value); this._disk.set(key, value); process.nextTick(callback);