This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi! I`ve read article about the second-level cache. And there are some cases, when 2-level cache hit occurs: - when you fetch an entity by Id, - when you fetch a collection of entities - and when you lazy load a collection or entity For example, we have entity Car and entity Wheel. Car`s got a collection of Wheels. Car and Wheel are both marked as Cached. But every time I touch Car.Wheels collection (that is, I use lazy load a collection), LightSpeed loads collection from the data base, not from cache. Why? Is there any way to use the 2-level cache during lazy load a collection? Thanks! |
|
|
LightSpeed will always execute a database query to find the result set for a lazy load and then check if the entities are in the cache before materializing them from the result set. It needs to do this to verify what is actually in the set at the time you execute the query. So a cache hit would occur in this scenario if one of the entities cached is in the result set for the lazy load. If you want to cache a "FindAll" style result you can specify this by applying the CacheFindAllResult attribute on your entity class definition - see: http://www.mindscapehq.com/forums/Post.aspx?ThreadID=3745&PostID=12910 for more details. This will only cover you for UnitOfWork.Find<MyEntities>() queries / UnitOfWork.MyEntities.ToList() if using LINQ though so may not help if you are only interested in lazy load scenarios.
Jeremy
|
|