l2-cache
L1L2Cache === this module is a helper to aid a consume two layers cache
Last updated 2 months ago by luizzamboni .
ISC · Original npm · Tarball
$ cnpm install l2-cache 
SYNC missed versions from official npm registry.

L1L2Cache

this module is a helper to aid a consume two layers cache

dependencies

  • redis

usage


  /* config to point a instance of redis */
  const config = {
    url: "redis://localhost"
  }

  /* when cache value is not found, this callback was update*/
  const updateCallback = function*(l1, l2) {
    // ... update logic, send to a queue or update here
  }

  const l2Cache = new L2Cache(config, updateCallback)

  /* first time cache value is not found*/
  const ad = l2Cache.get("http://api.example.com/ads/abc")
  /* null */

  /* in second time, value already was updated */
  const ad = l2Cache.get("http://api.example.com/ads/abc")
  /* {
    id: "abc",
    cpc: 0.4
  } */

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |