<commit_before>var Lru = require("lru-cache");

var memoryStore = function(args) {
    args = args || {};
    var self = {};
    self.name = 'memory';
    var ttl = args.ttl;
    var lruOpts = {
        max: args.max || 500,
        maxAge: ttl ? ttl * 1000 : null
    };

    var lruCache = new Lru(lruOpts);

    self.set = function(key, value, options, cb) {
        lruCache.set(key, value);
        if (cb) {
            process.nextTick(cb);
        }
    };

    self.get = function(key, options, cb) {
        if (typeof options === 'function') {
            cb = options;
        }
        var value = lruCache.get(key);
        if (cb) {
            process.nextTick(function() {
                cb(null, value);
            });
        } else {
            return value;
        }
    };

    self.del = function(key, options, cb) {
        if (typeof options === 'function') {
            cb = options;
        }
        lruCache.del(key);
        if (cb) {
            process.nextTick(cb);
        }
    };

    self.reset = function(cb) {
        lruCache.reset();
        if (cb) {
            process.nextTick(cb);
        }
    };

    self.keys = function(cb) {
        var keys = lruCache.keys();
        if (cb) {
            process.nextTick(function() {
                cb(null, keys);
            });
        } else {
            return keys;
        }
    };

    return self;
};

var methods = {
    create: function(args) {
        return memoryStore(args);
    }
};

module.exports = methods;
<commit_msg>Pass dispose, length & stale options to lru-cache<commit_after>var Lru = require("lru-cache");

var memoryStore = function(args) {
    args = args || {};
    var self = {};
    self.name = 'memory';
    var ttl = args.ttl;
    var lruOpts = {
        max: args.max || 500,
        maxAge: ttl ? ttl * 1000 : null,
        dispose: args.dispose,
        length: args.length,
        stale: args.stale
    };

    var lruCache = new Lru(lruOpts);

    self.set = function(key, value, options, cb) {
        lruCache.set(key, value);
        if (cb) {
            process.nextTick(cb);
        }
    };

    self.get = function(key, options, cb) {
        if (typeof options === 'function') {
            cb = options;
        }
        var value = lruCache.get(key);
        if (cb) {
            process.nextTick(function() {
                cb(null, value);
            });
        } else {
            return value;
        }
    };

    self.del = function(key, options, cb) {
        if (typeof options === 'function') {
            cb = options;
        }
        lruCache.del(key);
        if (cb) {
            process.nextTick(cb);
        }
    };

    self.reset = function(cb) {
        lruCache.reset();
        if (cb) {
            process.nextTick(cb);
        }
    };

    self.keys = function(cb) {
        var keys = lruCache.keys();
        if (cb) {
            process.nextTick(function() {
                cb(null, keys);
            });
        } else {
            return keys;
        }
    };

    return self;
};

var methods = {
    create: function(args) {
        return memoryStore(args);
    }
};

module.exports = methods;

{'fraction_non_alphanumeric': 0.13922859830667922, 'fraction_numerical': 0.004390090937597993, 'mean_word_length': 1.4240121580547112, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1161971', 'n_tokens_mistral': 1024, 'n_tokens_neox': 991, 'n_words': 218}