Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhon-henkel/local-storage-cache
Lib for local storage cache
https://github.com/jhon-henkel/local-storage-cache
cache-storage localstorage typescript
Last synced: about 2 months ago
JSON representation
Lib for local storage cache
- Host: GitHub
- URL: https://github.com/jhon-henkel/local-storage-cache
- Owner: Jhon-Henkel
- Created: 2024-06-18T19:17:47.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-22T14:06:40.000Z (7 months ago)
- Last Synced: 2024-10-28T16:13:37.315Z (2 months ago)
- Topics: cache-storage, localstorage, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@jhowrf/local-storage-cache
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Localstorage Cache
This is a package to use localstorage cache.
## How to use
Install the package
```bash
npm i @jhowrf/local-storage-cache
``````typescript
// import the package
import { localStorageCache } from '@jhowrf/local-storage-cache/src/localStorageCache'// to get a item from localstorage, only the key is required
const item = localStorageCache.getStorageItem("cache-key")// to set a item in localstorage, the key and the item are required.
// The third parameter is the time in milliseconds that the item will be stored in localstorage, the default value is 31536000000 (1 year)
localStorageCache.setStorageItem("cache-key", item, 31536000000)// to remove a item from localstorage
localStorageCache.removeStorageItems("cache-key", "cache-key-2")
```