Socket
Socket
Sign inDemoInstall

async-disk-cache

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-disk-cache

Async disk cache


Version published
Weekly downloads
356K
decreased by-8.35%
Maintainers
3
Weekly downloads
 
Created

What is async-disk-cache?

The async-disk-cache npm package is a simple and efficient way to cache data on disk asynchronously. It is useful for scenarios where you need to store and retrieve data quickly without relying on in-memory storage, which can be volatile and limited in size.

What are async-disk-cache's main functionalities?

Set Cache

This feature allows you to set a cache entry with a specific key and value. The data is stored on disk asynchronously.

const Cache = require('async-disk-cache');
const cache = new Cache('my-cache');

async function setCache(key, value) {
  await cache.set(key, value);
  console.log(`Cache set for key: ${key}`);
}

setCache('exampleKey', 'exampleValue');

Get Cache

This feature allows you to retrieve a cache entry by its key. It checks if the data is cached and returns the value if it exists.

const Cache = require('async-disk-cache');
const cache = new Cache('my-cache');

async function getCache(key) {
  const result = await cache.get(key);
  if (result.isCached) {
    console.log(`Cache hit for key: ${key}, value: ${result.value}`);
  } else {
    console.log(`Cache miss for key: ${key}`);
  }
}

getCache('exampleKey');

Remove Cache

This feature allows you to remove a cache entry by its key. The data is deleted from the disk asynchronously.

const Cache = require('async-disk-cache');
const cache = new Cache('my-cache');

async function removeCache(key) {
  await cache.remove(key);
  console.log(`Cache removed for key: ${key}`);
}

removeCache('exampleKey');

Clear Cache

This feature allows you to clear all cache entries. It removes all data stored in the cache asynchronously.

const Cache = require('async-disk-cache');
const cache = new Cache('my-cache');

async function clearCache() {
  await cache.clear();
  console.log('All cache cleared');
}

clearCache();

Other packages similar to async-disk-cache

Keywords

FAQs

Package last updated on 30 Oct 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