Sha256: f0952349ac3157a20b0e3b52e3dcd62407c4589db1dcff80b8a9c689693fcd9b
Contents?: true
Size: 692 Bytes
Versions: 14
Compression:
Stored size: 692 Bytes
Contents
// Limit cache size, LRU (least recently used) algorithm. 'use strict'; var toPosInteger = require('es5-ext/number/to-pos-integer') , lruQueue = require('lru-queue') , extensions = require('../lib/registered-extensions'); extensions.max = function (max, conf, options) { var postfix, queue, hit; max = toPosInteger(max); if (!max) return; queue = lruQueue(max); postfix = (options.async && extensions.async) ? 'async' : ''; conf.on('set' + postfix, hit = function (id) { id = queue.hit(id); if (id === undefined) return; conf.delete(id); }); conf.on('get' + postfix, hit); conf.on('delete' + postfix, queue.delete); conf.on('clear' + postfix, queue.clear); };
Version data entries
14 entries across 7 versions & 1 rubygems