I have an endpoint where I can request multiple pieces of data (such as https://example.com/things?ids=1,2,3
) that I'm querying using Siesta. I'm trying to figure out the proper behavior of my persistent entity cache if I only have some of the things
cached. So, if I have thing 1 and thing 2, but not thing 3 cached, I'd like to return a partial hit and have Siesta also query my server with the original URL. However, my understanding is that if EntityCache.readEntity
returns anything, then Siesta assumes that the query was fully fulfilled, and does not continue on to make the network request.
Is there a good way for me to implement a partial hit, or do I need to return nil
from readEntity
and wait for a response from the server?
Have your cache return the partial content with an Entity.timestamp
in the distant past. (It’s fine to use zero.) This will cause the 1,2 partial content to appear immediately on launch and when offline, but loadIfNeeded()
will consider that content stale and thus still trigger the request for 1,2,3.