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 understand that lightspeed only caches when an entity is found by id. If it is located by a linq where clause it won't be cached. Is this coming in v4? In the meantime I was wondering if it could be achieved via manually caching a result and using sql cache dependancy to remove it. I found this article for doing something similar with linq to sql but I'm uncertain how to replicateit with lightspeed. Is there any workaround you know of/ recommend? http://www.dotnetcurry.com/ShowArticle.aspx?ID=263
|
|
|
Have a look at this thread http://www.mindscapehq.com/forums/Thread.aspx?ThreadID=3745 for caching of an entire table set with cache invalidation at the LightSpeed level (which is what the linked article is doing except it does it at the database level using the Sql Server specific cache dependancy bits). You could then use unitOfWork.Find<T>() as the root for your LINQ queries which would be equivilant to the linked example - again please be mindful of the potential perf impact of this if you are dealing with larger tables. Or you could just adapt the above code to target LightSpeed without too much fuss if you would prefer the cache invalidation to happen at the db level.
Jeremy |
|
|
I can't really cache the entire table in most cases.
Cant you point me in the right direction for getting the table mappings and sql command for lightspeed queries. I can't quite figure it out. |
|
|
If you cant cache the entire table then the approach mentioned in that link would also not be appropriate as that is what it does. In terms of getting "table mappings" and "sql command", could you elaborate on what you are looking for here? If you are meaning working with a SqlCommand object then what you want to do is create one and then call the UnitOfWork.PrepareCommand method to attach it to the connection held by the UnitOfWork, you can then work with it as required.
Jeremy |
|
|
Sorry I must have missunderstood what the article was talking about. What I want to do is cache the results of a query and have that cache dependant on the db so that when it changes the cache is cleared for that query. The sql dependancy requires a sqlcommand object be passed to it, i wondered if there was an underlying sql command that made the lightspeed selects I could access. Is this doable or am I asking for the wrong thing? |
|
|
You wont be able to get access to the SqlCommand objects which LightSpeed uses internally. Do you actually need to have the cache invalidation managed at the database level though or is this something which would work sensibly at the application level? If its the latter you should have a look at using a Repository pattern approach and then you could fairly easily add caching into your method calls - this would obviously be a manual implementation however as there is nothing specific that we provide in LightSpeed for query caching at this stage.
Jeremy |
|