Socket
Socket
Sign inDemoInstall

@algolia/cache-browser-local-storage

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/cache-browser-local-storage

Promise-based cache library for browser using local storage.


Version published
Weekly downloads
1.5M
decreased by-3.64%
Maintainers
3
Weekly downloads
 
Created

What is @algolia/cache-browser-local-storage?

@algolia/cache-browser-local-storage is an npm package that provides a caching mechanism using the browser's local storage. It is designed to store and retrieve data efficiently, making it useful for applications that require persistent client-side caching.

What are @algolia/cache-browser-local-storage's main functionalities?

Set Cache

This feature allows you to set a value in the local storage cache with an optional expiration time. The code sample demonstrates how to set a key-value pair in the cache.

const { createBrowserLocalStorageCache } = require('@algolia/cache-browser-local-storage');
const cache = createBrowserLocalStorageCache();

cache.set('key', 'value', { expiresIn: 3600 }).then(() => {
  console.log('Value set in cache');
});

Get Cache

This feature allows you to retrieve a value from the local storage cache using a key. The code sample demonstrates how to get a value from the cache.

const { createBrowserLocalStorageCache } = require('@algolia/cache-browser-local-storage');
const cache = createBrowserLocalStorageCache();

cache.get('key').then(value => {
  console.log('Cached value:', value);
});

Delete Cache

This feature allows you to delete a value from the local storage cache using a key. The code sample demonstrates how to delete a key-value pair from the cache.

const { createBrowserLocalStorageCache } = require('@algolia/cache-browser-local-storage');
const cache = createBrowserLocalStorageCache();

cache.delete('key').then(() => {
  console.log('Value deleted from cache');
});

Other packages similar to @algolia/cache-browser-local-storage

FAQs

Package last updated on 18 Jul 2022

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