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

cache-base

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-base

Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects.

  • 4.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14M
decreased by-16.68%
Maintainers
2
Weekly downloads
 
Created

What is cache-base?

The cache-base npm package is a simple and fast key-value store for caching data. It provides an easy-to-use API for setting, getting, and managing cached data with support for namespaces and custom storage engines.

What are cache-base's main functionalities?

Setting and getting values

This feature allows users to store and retrieve data by key. The example shows how to set an object with user details and then retrieve it.

{
  const Cache = require('cache-base');
  const cache = new Cache();
  cache.set('user', { name: 'John Doe', age: 30 });
  console.log(cache.get('user'));
}

Using namespaces

Namespaces allow for organizing data under a specific context, avoiding key collisions and making data management clearer. The example demonstrates setting and getting data under a 'users' namespace.

{
  const Cache = require('cache-base');
  const usersCache = new Cache('users');
  usersCache.set('user1', { name: 'John Doe', age: 30 });
  console.log(usersCache.get('user1'));
}

Custom storage engines

Cache-base supports custom storage engines, allowing users to define how data is stored and retrieved. This example uses JavaScript's Map object as a custom storage engine.

{
  const Cache = require('cache-base');
  const customStore = new Map();
  const cache = new Cache({ store: customStore });
  cache.set('key', 'value');
  console.log(cache.get('key'));
}

Other packages similar to cache-base

Keywords

FAQs

Package last updated on 06 Nov 2021

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