Cache System
Caching view methods
There are two kinds of cache systems to be used. They are Memory Cache
and Storage Cache
.
Memory Cache
: will be cleared when the app refreshes, as its data lives in memory only.
Storage Cache
: The data will remain even when the browser tab is refreshed. Data is persisted using Local Storage.
When instantiating a cache, you need to provide the expirationTime
(in seconds). This is used to know when the cache should be returned instead of making a real contract call. When the cache expires, a real call to the contract is made. Each contract's method has its own time of expiration.
Then, to use cached view
, you can just pass the configuration object saying you want to use cached data.
Last updated