Noctiflorous Pansy Mulch
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    co-cacherpublic

    node-co-cacher

    A simple middleware for co library. Add cache opportunity for you function or generator

    example

    Add cache cache opportunity for simple generator - testGenerator:

    var co = require('co'),
        wait = require('co-wait'),
        cacher = require('co-cacher');
     
    var testGenerator = function* testGenerator (a) {
        yield wait(1000);
        return a+1;
    };
     
    co(function *(){
        var result = yield cacher(testGenerator, [4]);
        console.log(result); // wait 1 sec and get '5' 
        result = yield cacher(testGenerator, [4]);
        console.log(result); // get '5' from cache immediately 
    }).catch(function(e) {throw e; });

    simple test

    Start testing module:

    cd node-cache-wrapper
    $ npm install
    $ npm test

    config

    co-cacher use config module. Example of config (./config/default.js):

    module.exports = {
        // https://github.com/3rd-Eden/node-memcached 
        memcached: {
            servers: 'localhost:11211', // You can either use: String, Array, Object 
            options: {
                poolSize: 20
            }
        },
        cache: {
            expires: 120, // Default cache expires in seconds 
            storage: 'memcached',
            key: {
                prefix: 'cw_',
                crc32: false
            }
        }
    };

    roadmap

    • Add redis storage support

    Keywords

    none

    install

    npm i co-cacher

    Downloadslast 7 days

    11

    version

    0.0.4

    license

    none

    last publish

    collaborators

    • avatar