diff --git a/src/KeyvLru.js b/src/KeyvLru.js index 0e84fd4..be61466 100644 --- a/src/KeyvLru.js +++ b/src/KeyvLru.js @@ -2,6 +2,13 @@ import type { MapInterface } from '../flow/types/MapInterface'; +export type KeyvLruOptions = { + max: number, + notify?: boolean, + ttl?: number, + expire?: number, +}; + const lru = require('tiny-lru'); const EventEmitter = require('events'); @@ -13,14 +20,7 @@ class KeyvLru extends EventEmitter implements MapInterface { cache: Object; defaultTtl: ?number; - constructor( - options: { - max: number, - notify?: boolean, - ttl?: number, - expire?: number, - } = { max: 500 } - ) { + constructor(options: KeyvLruOptions = { max: 500 }) { super(); this.defaultTtl = options.ttl; this.cache = lru( diff --git a/src/KeyvLruManagedTtl.js b/src/KeyvLruManagedTtl.js index 17e3758..7d9f93e 100644 --- a/src/KeyvLruManagedTtl.js +++ b/src/KeyvLruManagedTtl.js @@ -1,6 +1,7 @@ // @flow import type { ExpirableItem } from '../flow/types/ExpirableItem'; +import type { KeyvLruOptions } from './KeyvLru'; const lru = require('tiny-lru'); const KeyvLru = require('./KeyvLru'); @@ -21,14 +22,8 @@ class KeyvLruManagedTtl extends KeyvLru { cache: Object; defaultTtl: ?number; - constructor( - options: { - max: number, - notify?: boolean, - ttl?: number, - } = { max: 500 } - ) { - super(); + constructor(options: KeyvLruOptions = { max: 500 }) { + super(options); this.cache = lru(options.max, options.notify); }