Giter VIP home page Giter VIP logo

proxy-cache's Introduction

proxy-cache

A proxying in-memory cache for node.

Installation

$ npm install segmentio/proxy-cache

Examples

var DB = require('db');
var cache = require('proxy-cache');

var db = new DB();
db.getUserById('id', function (err, user) {
  // fetches `user` from the db
});

db = cache(new DB(), ['getUserById']);
db.getUserById('id', function (err, user) {
  // fetches the user from the db 
  // and caches it in memory as `getUserById:id`
  db.getUserById('id', function (err, user) {
    // this lookup fetches `user` directly the from the cache
  });
});

API

.cache(instance, methods, options)

Generate a proxying cache, with all properties of instance fully proxied, and all instance methods wrapped with a cache. You can also pass in optional options, which line up exactly with isaacs/node-lru-cache options. Here are the defaults:

{
  max: 10000,
  maxAge: ms('1m'),
  stale: false,
  peek: true, // peek by default so maxAge is honored
  tombstone: true // save undefined values returned as well
}

License

WWWWWW||WWWWWW
 W W W||W W W
      ||
    ( OO )__________
     /  |           \
    /o o|    MIT     \
    \___/||_||__||_|| *
         || ||  || ||
        _||_|| _||_||
       (__|__|(__|__|

proxy-cache's People

Contributors

calvinfo avatar yields avatar

Stargazers

曹文忠 avatar Andrii Trybynenko avatar Emily Marigold Klassen avatar Qasim Zaidi avatar Ian Storm Taylor avatar Ilya Volodarsky avatar  avatar

Watchers

Prakash Durgani avatar Michael Schmatz avatar James Cloos avatar Achille avatar Andrius Vaskys avatar Julien Fabre avatar George Wolf avatar Rakesh Nair avatar  avatar Karthick Sriraman avatar  avatar Niels avatar  avatar Sam Johnson avatar  avatar  avatar Michael Phillips avatar Brent Summers avatar Alex Noonan avatar Teresa Nesteby avatar Chris Nixon avatar  avatar  avatar Zeb avatar Liz Hartmann avatar Arlen McCluskey avatar  avatar Ian Muceus avatar  avatar Emilio Gomez Lavin avatar  avatar Kate Flaming avatar  avatar

Forkers

magicdice

proxy-cache's Issues

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.