obj-cache

object cache for nodejs

npm install obj-cache
4 downloads in the last week
16 downloads in the last month

cache

Object cache for nodejs.

Getting Started

npm install obj-cache

API

var cache_object=new cache(name,keepalive,loader,dispose)

cache_object.get(key,callback)

cache_object.remove(key)

cache_object.clear()

cache_object.length

cache_object.dispose()

cache.cleanup()

Sample


var cache=require('obj-cache');
var mycache=new cache(
    'mycache',
    1000*30,
    function(key,callback)
    {
        database.connect(
            key,
            function(err,conn)
            {
                callback(err,conn);    
            }
            );
    },
    function(conn)
    {
        conn.close();
    }
);

...

mycache.get(
    'database connection string',
    function(err,conn)
    {
        conn.query(....);

    }
    );

....

//exiting application
cache.cleanup(); //release resource in all caches
npm loves you