@cc-heart/storage-cache
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

Storage Cache

Storage Cache is a library for scoping APIs stored in browser local storage, aimed at preventing conflicts when using APIs in the same origin environment.

Installation

You can install Storage Cache via npm:

npm install @cc-heart/storage-cache

Usage

Creating a StorageCache Instance

import { defineStorage } from '@cc-heart/storage-cache';

const { localStorageCache, sessionStorageCache } = defineStorage('namespace');

set data:

localStorageCache.setItem('key', 'value');
localStorageCache.setItem('key', 'value', 1000) // set expiration time
localStorageCache.setItem('key', 'value', 'EX', 1000) // set expiration time in second

get data:

localStorageCache.getItem('key') // value

remove data:

localStorageCache.removeItem('key')

clean up all storage under the scope:

localStorageCache.clear()

License

This project is licensed under the MIT License - see the LICENSE file for details.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.7
    0
    • latest

Version History

Package Sidebar

Install

npm i @cc-heart/storage-cache

Weekly Downloads

0

Version

0.0.7

License

MIT

Unpacked Size

19.8 kB

Total Files

21

Last publish

Collaborators

  • cc-heart