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

hmpo-cached-model

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmpo-cached-model

Cached polling model

  • 3.0.0
  • Source
  • npm
  • Socket score

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

hmpo-cached-model

Cached polling model.

Poll an API at a given interval and save the data to a data storoe such as redis. Multiple nodes can synchronise by sharing the redis instance and key.

Usage

const HmpoCachedModel = require('hmpo-cached-model');

let redisFactory = {
    getClient() {
        return redisInstance;
    }
}

let model = new HmpoCachedModel(
    { // optional seed data
        foo: 'bar',
        boo: 'baz'
    },
    { // options
        url: 'http://example.com/api',
        key: 'root-key',
        store: redisFactory,
        storeInterval: 1000,
        apiInterval: 2000
    }
);

// start polling
model.start();


let data = model.get('data');


// stop polling
countriesLib.stop();

If the API returns an object, all keys are saved to the model, otherwise the data from the API is saved to the data key.

Extend and override parse() to change the way the incomming data from the API is processed.

FAQs

Package last updated on 31 Jan 2020

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