0.0.5 • Published 3 months ago

@cc-heart/storage-cache v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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 } = new 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.

0.0.5

3 months ago

0.0.4

3 months ago

0.0.3

3 months ago

0.0.2

3 months ago

0.0.1

3 months ago