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

@appfarm/ttl-cache-redis

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appfarm/ttl-cache-redis

Simple abstraction of redis for storing strings and objects

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

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

ttl-cache-redis

This is a supersimple abstraction for storing strings and JSON-objects in redis.

Installing

Using npm:

$ npm install @appfarm/ttl-cache-redis

Example

const Cache = require('@appfarm/ttl-cache-redis')
const myCache = new Cache({
	redisConnectionString: 'redis://localhost:6379',
	cacheKeyPrefix: 'MY-CACHE-', // prefix any key with this value
})

// Setting "foo" to MY-CACHE-newkey with a
// lifetime of 10 minutes
myCache
	.setStringValue('newkey', 'foo', 600)
	.then(() => console.log('Successfully set string value'))
	.catch(err => console.error(err))

myCache
	.setObjectValue('myobject', { foo: 'bar' }, 300)
	.then(() => console.log('Successfully set object value'))
	.catch(err => console.error(err))

// Retrieve string value from cache
myCache
	.getStringValue(key)
	.then(value => {
		console.log('Found value:', value)
	})
	.catch(err => {
		console.log('Unable to find value or key has expired')
	})

// Retrieve object value from store
myCache
	.getObectValue(key)
	.then(objectValue => {
		console.log('Found object:', objectValue)
	})
	.catch(err => {
		console.log('Unable to find value or key has expired')
	})

// Fire and forget - delete value from store immediately
// Returns nothing.
myCache.invalidate('newkey')

Keywords

FAQs

Package last updated on 29 Aug 2019

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