import cache from 'react-native-cache-data';
cache.set('test', 'simple value').then(() => {
console.log('saved');
});
cache.get('test').then(result => {
console.log(result);
});
cache.remove('test').then(() => {
console.log('removed');
});
import cache, {expire} from 'react-native-cache-data';
const data = {
key1: 'value1',
key2: 'value2',
};
cache.set('test', data, [JSON.stringify]).then(() => {
console.log('saved');
});
cache.get('test', [expire(60), JSON.parse]).then(result => {
console.log(result);
});
import cache from 'react-native-cache-data';
const filterRedValueMiddleware = (value, date) => {
if (value && value !== 'red') {
return value;
}
return null;
};
cache.set('first', 'yellow').then(() => {
console.log('saved');
});
cache.set('second', 'red').then(() => {
console.log('saved');
});
cache.get('first', [filterRedValueMiddleware]).then(result => {
console.log(result);
});
cache.get('second', [filterRedValueMiddleware]).then(result => {
console.log(result);
});