A CacheManager implementation for local data caching in Relay
Relay defines the CacheManager
interface which lets you write and read records to a local cache. Relay will
check the cache first when identifying what data it has/needs; by implementing a CacheManager
you can render locally cached data quickly while Relay queries your API and updates the data when the response comes in.
$ npm install --save relay-cache-manager
In a browser environment:
import CacheManager from 'relay-cache-manager';
const cacheManager = new CacheManager();
Relay.Store.injectCacheManager(cacheManager);
With a custom cache storage provider (in React Native using AsyncStorage for example):
import CacheManager from 'relay-cache-manager';
const cacheManager = new CacheManager({
cacheStorageProvider: new AsyncStorageCacheStorageProvider(),
});
Relay.Store.injectCacheManager(cacheManager);