You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A localStorage-like wrapper around React Native's AsyncStorage with cache expiration.
100% inspired by @pamelafox's lscache. Currently being used by my project, hackerweb-ios.
WARNING: The test coverage is not very high 😅
Installation
npm i --save react-native-cache-store
API Reference
set(key, value, [time]) - Stores the value. Expires after specified number of minutes.
key (string)
value (Object | string)
time (number: optional)
get(key) - Retrieves specified value, if not expired.
key (string)
remove(key) - Removes a value.
key (string)
isExpired(key) - Checks if a value has expired.
key (string)
flush() - Removes all items.
flushExpired() - Removes all expired items. This method runs every time this code is initalized.
Example Usage
importCacheStorefrom'react-native-cache-store';CacheStore.set('key','value',10);// Expires in 10 minutesCacheStore.get('key').then((value)=>{// Do something with value});CacheStore.isExpired('key').then(()=>{/* true */}).catch(()=>{/* false */})