Giter VIP home page Giter VIP logo

cache-dir's Introduction

stable NPM version Build Status Coverage Status Dependency Status

cache-dir

An ES6 map-like cache with file-based backing

Example

var CacheDir = require("cache-dir");

var cache = new CacheDir({
    dir: '/path/to/store/cache',
    namespace: 'dirNameForThisParticularCache',
    lazy: true // Lazy load or eagerly load from disk on startup, eager by default
});

cache.setSync('foo', 'bar'); // This actually blocks on the fs write
cache.getSync('foo'); // returns bar

cache.set('foo2', 'bar2', function(err) {
    console.log("This doesn't block the event loop on the write");
    console.log("And the callback is optional, so you don't need to check " + err && err.message);
});

cache.get('foo2', function(err, val) {
    console.log(val, 'contains "bar2"');
});

cache.keysSync(); // Returns an array of keys
cache.keys(function(err, keys) {
    console.log("also returns an array of keys");
});

cache.valuesSync(); // Returns an array of values
cache.values(function(err, values) {
    console.log("also returns an array of values");
});

Other ES6 Map methods and properties are not yet implemented.

Installation

npm install cache-dir

Tests

npm test

Contributors

  • David Ellis

cache-dir's People

Contributors

jcorbin avatar raynos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ahmad-saleem

cache-dir's Issues

JSON.parse can throw (duh)

SyntaxError: Unexpected end of input
at Object.parse (native)
at CacheDir. (/home/uber/rt-tia/node_modules/cache-dir/index.js:17:37)
at Array.forEach (native)
at new CacheDir (/home/uber/rt-tia/node_modules/cache-dir/index.js:16:39)
at Object. (/home/uber/rt-tia/bin/tia_server.js:33:18)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.