Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fwsp-cacher

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fwsp-cacher

A caching module for use with Node and Redis

  • 1.0.3
  • experimental
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
2
Weekly downloads
 
Created
Source

Cacher

npm version NPM downloads npm Libraries.io for GitHub

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

Package last updated on 10 May 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc