l2-cache

1.0.0 • Public • Published

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
  } */
 

Readme

Keywords

none

Package Sidebar

Install

npm i l2-cache

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • luizzamboni