1.1.0 • Published 4 years ago
react-native-async-storage-cache v1.1.0
Important Note
This is a Fork of react-native-clcasher which needs to use the AsyncStorage from the react-native-community.
MemoryCache
Extended AsyncStorage with expiration check
AsyncStorage can only save data forever. If you want save data for some period of time and clean outdated data - use following API:
set(key: string, value?: mixed, expires?: seconds)- Stores data by key and expiration time in secondsget(key: string)- Returns stored data by keyremove(key: string)- Clear data by keymultiGet(keys: array)- Get data by keysmultiSet(values: object, expires?: seconds)- Store multiple data with expiration time in secondsmultiRemove(keys: array)- Clears storage by specified keysflush()- Clear storageisExpired(key: string)- Checks of data expirationgetAllKeys()- Returns all stored keysgetAllValues()- Returns all stored serialized values
Installation
npm install --save react-native-async-storage-cacheUsage
const MemoryCache = require('react-native-async-storage-cache/MemoryCache').default;
import { MemoryCache } from 'react-native-async-storage-cache/MemoryCache';
MemoryCache.set(url, headers, maxAge)