Replies: 5 comments
-
Try removing |
Beta Was this translation helpful? Give feedback.
-
Thanks but removing the fetch performed slightly worse as now it adds an extra hit to the database when it first calls the |
Beta Was this translation helpful? Give feedback.
-
I see it's been discussed here #1922 (comment) And if I understand correctly lazy property initialization should be propagated to cache (at least lazy loaded case after #1949) Seems @maca88 is the best person to shed the light on it... |
Beta Was this translation helpful? Give feedback.
-
The cache disables itself quite fast when you use it without transactions. Please wrap all your session usage inside transactions, to make sure the lack of transaction is not the issue. See here:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @fredericDelaporte but wrapping the calls in a transaction didn't seem to make much difference. Here's my updated sample application: Looking at the changes in the #1949 pull request (by @maca88) I should be able to create a test case for this if you feel it's a bug? |
Beta Was this translation helpful? Give feedback.
-
I have an issue when I wish to retrieve an entity (which has already been cached) but this time I fetch a lazy loaded property it will trigger a hit to database. For example say I have the following models:
Which are mapped like so:
Here's my sample application, indicating each time the database is hit:
Notice when I try to retrieve an entity via
GetContentItemAsync
(which has already been cached byGetAllContentItemsAsync
), the first time it does a fresh hit to the database (to fetch the lazy loaded data as requested) but the cache is not updated. Now any further calls to the lazy loaded data will also trigger a hit to the database since I assume was because it was not included in the original query which cached the entity.I've been playing around with the cache mode but each one seems trigger a fresh hit to the database which defeats the purpose of a cache.
I was originally writing this as a bug but then I looked at the docs and realized that the query cache just caches the id's and the entity cache is responsible for caching the values.
I'd appreciate if someone could show me a way around this as I can imagine this is quite a common scenario. For example if you have paged list of blog posts which are cached and then you click through to the details page which contains more details, you wouldn't want to load all of the data on the list page.
Beta Was this translation helpful? Give feedback.
All reactions