Hi Team,
Is their any api to get the sync response. i.e. when I try to access this https://api.us-east-1.mbedcloud.com/v2/endpoints/{device-id}/5001/0/1 it is returning AsyncIDResponse, for that I need to register a callback. But I want the response from cache instead of AsyncID.
bridadan
(Brian Daniels)
February 20, 2018, 3:51pm
2
Hi @ispacedroid ,
I took a look at the API docs (https://cloud.mbed.com/docs/v1.2/service-api-references/connect-api.html ). You can force a response from the cache by using the cacheOnly=true
query parameter.
Ex.
GET https://api.us-east-1.mbedcloud.com/v2/endpoints/{device-id}/5001/0/1?cacheOnly=true
There are two possible successful responses:
200
- Returns a value from the cache
205
- No value is returned because there is not a value in the cache for the resource
Hope that helps!
-Brian
ispacedroid
(ispace droid)
February 21, 2018, 10:41am
3
bridadan:
/0/
Hi Bridadan,
Thanks for the reply. I tried by adding cacheOnly=true but it is always returning 205 i.e. NOT_IN_CACHE.
If I try try by making cache as false and pull, at that time it is returning the value. So shill I need to enable any flag while writing the values to cloud from device.
bridadan
(Brian Daniels)
February 21, 2018, 3:44pm
4
I don’t think you need to do much besides setting the resource’s “max age” to a reasonable time. You can find information about that API here: https://cloud.mbed.com/docs/v1.2/collecting/working-with-the-resources.html#working-with-the-server-cache
You can also read up a bit more on the server cache here: https://cloud.mbed.com/docs/v1.2/connecting/device-guidelines.html#resource-cache
Let me know if that works!
1 Like