Socket
Socket
Sign inDemoInstall

fwsp-cacher

Package Overview
Dependencies
6
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fwsp-cacher

A caching module for use with Node and Redis


Version published
Weekly downloads
78
increased by30%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Cacher

A simple module for caching using Redis.

Introduction

Cacher is a wrapper module to abstract cache details and handling in order to make it easier for clients to simply get and set cached data.

Cacher has five public functions: init, setCachePrefix, getData, setData and setTTL. The most common methods you'll use after init will be the getData and setData methods.

####init

Used to initialize a cacher object with an object containing the address, port and database number for use with Redis.

let cacher = new Cacher();
cacher.init({
  url: '127.0.0.1',
  port: 6379,
  db: 1  
});
setCachePrefix

By default Cacher prefix keys in Redis with the word cacher. To specify an alternative prefix use the setCachePrefix member.

cacher.setCachePrefix('myAppName');
getData
/**
 * @name getData
 * @summary Retrieve data from cache using key.
 * @param {string} key - lookup key
 * @return {object} promise - promise resolving to value of key or rejection
 */
 getData(key)
setData
/**
 * @name setData
 * @summary Place data in cache based on key for a duration of cacheDurationInSeconds.
 * @param {string} key - lookup key
 * @param {object} data - data to store at key
 * @param {number} cacheDurationInSeconds - cache expiration
 * @return {object} promise - resolving to success or rejection
 */
 setData(key, data, cacheDurationInSeconds)
setTTL
/**
 * @name setTTL
 * @summary Set Time To Live for cache entry associated with key.
 * @param {string} key - key to set
 * @param {number} cacheDurationInSeconds - seconds to reset expiration to
 * @return {object} promise - resolving to success or rejection
 */
 setTTL(key, cacheDurationInSeconds)

Tests

This module contains tests in the specs folder.

To run them make sure you have mocha installed:

$ npm install mocha -g

Then run:

$ npm run test

FAQs

Last updated on 08 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc