🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

lim-cache

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lim-cache

Test library

latest
Source
npmnpm
Version
4.0.7
Version published
Maintainers
1
Created
Source

lim-cache

Limited Persistent Storage Cache

Installation

yarn add lim-cache

Usage

import { createStorage } from "lim-cache";

const config = {
  limit: 10000
}

const storage = createStorage(config);

Storage object

  • set(key: string, value: any): void Saves value with specific key to cache.
  • get(key: string): any Get value by key.
  • remove(key: string): void Removes value with specific key from cache, returns value.
  • clear(): void Removes all values from cache.

LocalStorage middleware

Local storage middleware allows you to save your cache into browser localStorage.

import { withLocalStorage } from "lim-cache";

const localStorageConfig = {
  name: "myStorage",
  blacklist: ["DoNotPersist"]
}

const storage = createStorage(config, withLocalStorage(localStorageConfig))

Configuring:

  • name: with this name data will be saved into localStorage (usefull if you have more then one storage).
  • blacklist: list of keys that will not be saved to localStorage, but will still be saved to RAM.

FAQs

Package last updated on 13 Nov 2018

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