Socket
Socket
Sign inDemoInstall

rss-cache

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rss-cache

A synchronous node cache package based on redis sub & pub


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.1.3

remove src from npm package

Readme

Source

rss cache for node

A node cache lib
Can be used alone without a message queue system
Or Can sync data between server or pm2 process depends on redis, or some other message queue.

Install

npm install rss-cache

Usuage

basic cache from cache a function result

const rssCache = new RssCache('mycache', 10 * 60 * 1000)
const key = 'cacheKey'
const value = rssCache.get(() => { return parseInt(Math.random(100) * 100) }, key)

async cache for cache a promise

const rssCache = new RssCache('mycache', 10 * 60 * 1000)
const key = 'cacheKey'
const val = rssCache.get(new Promise((resolve) => {
  setTimeout(() => {
    resolve(parseInt(Math.random(100) * 100))
  }, 1000)
}), key)
val.then((value) => {
  res.write(`get key [${key}]: ${value}`);
  res.end();
})

sync between servers or diffrent processes, depend on redis pub/sub

you can allso depend on others message queue

RssCache.initSync(new RssRedis({channel: 'RssCacheChannel', host: 'localhost'}))

Examples

you can try it with
npm install -g pm2
rm -rf dist && npm run build && cd dist/examples && pm2 start demo.js -i 2
then visist
http://localhost:6060/?key=b
http://localhost:6060/?key=b&type=clear
http://localhost:6060/?key=c&sync=async
in your browser

Keywords

FAQs

Last updated on 08 Nov 2019

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