Clarification on what exactly is cached by EF Plus


If I have a table of service requests and I run the following code on it:

var serviceRequest = await _ctx.ServiceRequests.DeferredAny(t => t.Id == h.Id).FromCacheAsync("ServiceRequestByID");

Would that be the same as saying save this query:

SELECT * FROM ServiceRequests WHERE ID = 12345

or is it the same as saying:

SELECT * FROM ServicesRequests (Then from that newly cached data find id 12345).

In other words, what exactly is cached in regards to using the line of code above? And if I come back later with a new ID, then will it query the cache or go to the database because it saved only the first ID's record the first time?

Accepted Answer

The result is cached.

In your case, the boolean value result is cached and not the entity.

If you query with a different ID, it will query the database and cache the result as well with the other result

Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why