Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mirinzhang/react-native-expire-storage
Use react-native AsyncStorage storage data by add expiration time
https://github.com/mirinzhang/react-native-expire-storage
asyncstorage react-native
Last synced: 11 days ago
JSON representation
Use react-native AsyncStorage storage data by add expiration time
- Host: GitHub
- URL: https://github.com/mirinzhang/react-native-expire-storage
- Owner: mirinzhang
- Created: 2018-10-19T14:00:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-25T05:55:25.000Z (over 4 years ago)
- Last Synced: 2024-04-23T23:15:38.148Z (7 months ago)
- Topics: asyncstorage, react-native
- Language: JavaScript
- Size: 7.81 KB
- Stars: 13
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-expire-storage
Use react-native AsyncStorage storage data by add expiration time
### Install
```bash
npm i -S react-native-expire-storage
```### Usage
```javascript
import Storage from 'react-native-expire-storage';// setItem
/**
* Set storage
* @param {string} key storage key
* @param {any} value storage data
* @param {number} expire expiration time(second)
*/
Storage.setItem('key1', {data: {name: 'tom', age: 12}, id: 0, str: 'key1 data'}, 60 * 60);Storage.getItem('key1'); // {data: {name: 'tom', age: 12}, id: 0, str: 'key1 data'}
Storage.mergeItem('key1', {{data: {age: 13}, str: 'key1 data changed'}});
Storage.getItem('key1'); // {data: {name: 'tom', age: 13}, id: 0, str: 'key1 data changed'}
Storage.getAllKeys(); // ['key1']
Storage.removeItem();
// Storage.clear() // clear all storage data
Storage.getItem('key1'); // null
```