Module: cache

cache

Interception module for caching the results returned by the intercepted methods.

IMPORTANT: this interceptor breaks the call chain and returns immediately if the requested item is cached, therefore subsequent interceptors and the method itself will not be invoked.

The interceptor uses node-cache-manager library for caching. Please refer to node-cache-manager documentation for more details on configuration and usage.

For more details on using interceptors please see the Interceptors tutorial.

Source:

Example

 var entree  = require("entree"),
     cache     = entree.resolveInterceptor("cache"),
     stores    = [
         { store: "memory", max: 1000, ttl: 10 },
         { store: require("./redis_store"), db: 0, ttl: 100 }
     ];

entree.posts.use(cache.interception(stores, ["get"]));

Methods

<static> interception(stores, actions) → {function}

Configures and returns an interceptor function.

Parameters:
Name Type Argument Description
stores object <optional>

defines the cache stores. By default only memory store is used with the following configuration: { store: "memory", max: 1000, ttl: 10 }.

actions string | Array.<string> <optional>

Specifies which actions (methods) should be cached. Could be single action or an array of actions. If omitted, all actions are cached. Possible values are: ["insert", "upsert", "update", "get", "delete", "select"]

Source:
Returns:
Type
function
EntreeJS Copyright © 2013-2014 The contributors to the EntreeJS project.
Documentation generated by JSDoc 3.2.2 on Mon May 26 2014 17:43:42 GMT+0300 (EEST) using the DocStrap template.