Socket
Socket
Sign inDemoInstall

disk-cache

Package Overview
Dependencies
5
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    disk-cache

Simple disk caching


Version published
Weekly downloads
10
increased by11.11%
Maintainers
1
Install size
4.10 MB
Created
Weekly downloads
 

Readme

Source

disk-cache

Build Status

Simple disk caching - cache strings to files on disk

Installation

npm install disk-cache

Methods

cache.get(key, [ttl], cb)

cache.set(key, value, cb)

Usage

var cache = require('disk-cache')({
  path: './cache/' + Math.random()
})

var key = 'some/file.txt'
var value = 'abc123'
cache.set(key, value, function(err) {

  var ttl = 60 * 60 // 1 hour
  cache.get(key, ttl, function(err, val) {

    if (err.notFound) {
      // this value is not cached or has expired
      return
    }

    console.log(val) // abc123
  })
})

Keywords

FAQs

Last updated on 09 Jan 2015

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