You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Amplify
I'd like to have the following behaviour :
I execute a first request. The request succeed. I retrieve the data,
and store it in the cache.
I execute a second request. The request succeed. I retrieve the data,
and store it in the cache.
The server became unavailable.
I execute a third request. The request fail. I retrieve the data from
the cache.
Further requests will retrieve data from the cache until the request
succeed.
The server became available.
I execute a final request. The request succeed. I retrieve the data,
and store it in the cache.
I'd like to use the cache as a fallback when the server is not
available.
Is it possible with a custom cache definition or by any other way ?
Scott González
unread,
Mar 16, 2012, 8:04:26 PM3/16/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ampl...@googlegroups.com
You should be able to do this with a custom cache type. You'll want to cache the value on success and inspect the error code on error to determine if you want to treat it as a success anyway (because of the cache). This is pretty different from all of the built-in cache types since you'll never short-circuit the request from the cache. I'd suggest looking at how the in-memory cache is implemented to get an idea of how to implement a custom cache: https://github.com/appendto/amplify/blob/64fd940805f5eeced23cc7a56ab7fb6eef7d23de/request/amplify.request.js#L284