New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cache-lite

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-lite

Node in-memory caching system

latest
Source
npmnpm
Version
0.0.6
Version published
Weekly downloads
9
-43.75%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Badge)

cache-lite CircleCI

Description

Simple node in-memory caching system

Download

The source is available for download from GitHub. Alternatively, you can install using Node Package Manager (npm):

  npm install cache-lite

Example

const CacheLite = require('cache-lite');

const cache = new CacheLite()

// Set value in the cache for 200ms
cache.set("myKey", "myData", 200).then(() => {
})

// Get value from the cache
cache.get("myKey").then((value) => {
  console.log(value); // myData
})

cache.getKeys() // [ 'myKey' ]

cache.size() // 1

//Get value from the cache after 300ms
setTimeout(() => {
  cache.get("myKey").then((value) => {
  }).catch((err) => {
    // Error: The key myKey doesn't exist in the cache
  })
}, 300);

API

###set(key, value, ttl) Returns a promises

key

Type: string

Key

value

Type: string

Value

ttl (optional)

Type: number

Time to live

###get(key) Returns a promises

key

Type: string

Key

###getKeys() Returns keys stored in the cache

###size() Returns the number of elements in the cache

###clear() Delete all cached values from the cache

Requirement

Node >= 5.0

License

MIT © Thomas Blanc-Hector

Keywords

cache

FAQs

Package last updated on 26 Jun 2016

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