2.0.0 • Published 9 years ago

node-ciks v2.0.0

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
9 years ago

node-ciks

Cache (library and service) implementation for nodejs.

Install

$ npm install node-ciks

Usage

var ciks = require('../src/ciks').cache;
var mstorage = require('../src/memory-ciks/memory.js').storage;

var cache = new ciks();
var storage = new mstorage();
cache.storage(storage);

/// Now you can register cache producers, populate values and get cached ones.

For more use detailed cases please refer to example

Functions

ciks.storage(storage)

Sets cache storage. Params:

  • storage — Instance of one of storage class. Currently only MongoDB and In-Memory storage supported.

ciks.register(alias, producer, ttlProducer)

Registers new data producer function. Params:

  • alias — Producer function alias.
  • producer — Callable producer function.
  • ttlProducer — Callable function that produces cache TTL based on options passed to producer function.

ciks.get(alias, options, promise)

Gets data from cache or populate it.

  • alias — Producer function alias.
  • options — Options to pass to producer function to populate data.
  • promise — Promise to resolve when data is populated.

ciks.populate(alias, options, promise)

Populates new data and store it to cache.

  • alias — Producer function alias.
  • options — Options to pass to producer function to populate data.
  • promise — Promise to resolve when data is populated.
2.0.0

9 years ago

1.0.0

9 years ago

0.0.1

9 years ago

0.1.0

9 years ago