jaredwray / flat-cache

A stupidly simple key/value storage using files to persist the data
MIT License
165 stars 30 forks source link

The cache is overwritten #4

Closed xuexb closed 8 years ago

xuexb commented 9 years ago
var flatCache = require('flat-cache');
var cachePath = './__cache/';

// Written three key
var cache = flatCache.load('cacheId', cachePath);
cache.setKey('key', {
    foo: 'var'
});
cache.setKey('key2', {
    foo: 'var2'
});
cache.setKey('key3', {
    foo: 'var3'
});
cache.save();
// => {"key":{"foo":"var"},"key2":{"foo":"var2"},"key3":{"foo":"var3"}}

// I want to use only one key, but I 'll cover the other key when you save
var cache2 = flatCache.load('cacheId', cachePath);
cache2.setKey('key', {
    foo: 'var'
});
cache2.save();
// => {"key":{"foo":"var"}}

Under normal circumstances , I would like to use a key, but do not want to cover the rest, I do not know whether there is such a demand problem , thank you~

xuexb commented 8 years ago

This I realized key-cache, look forward to reading your ~ Thank you