13 Answers, 1 is accepted
Generally, Second Level Cache of Telerik OpenAccess ORM is a cache used by all instances of OpenAccessContext created from a single application. It resides in the application process and is populated during read access of the database. More details about its capabilities, how to maintain it and how to set it up, you can read in this set of articles.
In fact, it is suitable in all scenarios that include multi-threading but its optimal usage is with Web applications. There you have thread pooling and open a new context for all incoming calls. In this scenario, database access is necessary only when the data, which needs to be retrieved is not currently available in the cache. The end result from using 2nd Level Cache is increased efficiency and performance of your application.
If you have any additional questions, do not hesitate to get back to us.
Greetings,
Doroteya
the Telerik team
If the object is modified from within the same application (i.e uses the same connection string and credentials) OpenAccess will clear all objects of the type that has been modified and the next time the query is executed the objects will be fetched from the database.
In case the object is modified by another application you would need to manually evict objects of that type from the L2 cache using the 'context.LevelTwoCache.EvictAll<T>()' method.
Do get back in case you need further assistance.
Kind regards,
Ady
the Telerik team
You would need to setup the cache cluster in order to synchronize the caches. You can find more information about the cache cluster, here.
Do get back in case you need further assitance.
All the best,
Ady
the Telerik team
I see your provided link. Whether there is a way to specify the cache is hosted in a standlone cache server? I see your implementation will use MSMQ. Whether there are some delay while synchronize the caches between mutipule server? For example, I have 3 servers which all enable L2 cache. If I modify one record, whether it will refresh cache for updated record in 3 server at the same time?
The concept, as described in the link before, of the L2 cache is to use MSMQ as a transport layer to inform other participants in the environment about the changes. Basically every OpenAccess database process you are running has it's own data cache. If something is changed, then we generate meta information of what to evict from the cache. Other database processes will be informed, by sending an evict message via the specified multicast address.
This information is optimized to not send more then needed the actual data is not transmitted. As soon as the evict message arrives at the particular database process, it will be deleted from its data cache.
Depending on your infrastructure (network speed, etc.), there could be a potential inconsistency in your caches between your Database processes but I strongly believe that this timeframe is very short.
At the moment there is no concept in Telerik OpenAccess ORM to use a standalone cache server.
I hope this information is helpful for you.
Do come back if you need further assistance.
Ralph
the Telerik team
The cache is stored in the memory of your application.
Feel free to ask if you have any other question.
Ralph
the Telerik team
Level 2 Cache resides in the memory of the application server. It is available to all callers only in the application domain of the first data context query. This means that if two application use the same OpenAccess model they will not share their Level 2 Cache.
I hope that this clears things up.
All the best,
Viktor Zhivkov
the Telerik team
2."This means that if two application use the same OpenAccess model they will not share their Level 2 Cache.", What's the definition for the 'application', different connection string or what else?
1. Yes, the Level 2 Cache is populated during a database access.
2. Each type of project including web sites are separated applications and have their own application domains. The application does not depend on the number of the different connection string.
The 2nd level cache is designed to implement a multithreaded application, where every single thread has its own context. If you need to have the cache working on a higher level (to be shared between many applications) you could use our L2 Cache Cluster.
It provides the ability to synchronize the L2 caches of many applications that operate on the same database. To achieve this, each modifying transaction sends messages to all participants in the cluster, so they can evict the outdated data. This communication is done in an asynchronous way– there is a very short time-frame, in which one L2 cache could be evicted but another L2 cache could still hold old data.
If you want to use a L2 cache cluster, you can follow the steps below to enable it:
1. Create a partial class of your domain model – like in the attached image.
2. Override the OnDatabaseOpen method with the following code:
protected
override
void
OnDatabaseOpen(Telerik.OpenAccess.BackendConfiguration backendConfiguration, Telerik.OpenAccess.Metadata.MetadataContainer metadataContainer)
{
backendConfiguration.SecondLevelCache.Enabled =
true
;
backendConfiguration.SecondLevelCache.Synchronization.Enabled =
true
;
backendConfiguration.SecondLevelCache.Synchronization.MulticastAddress =
"224.1.1.1:666"
;
backendConfiguration.SecondLevelCache.Synchronization.Name =
"MSMQ"
;
base
.OnDatabaseOpen(backendConfiguration, metadataContainer);
}
In this documentation section you could find more information about working with 2nd Level Cache in a Distributed Environment.
I hope this helps.
Dimitar Tachev
the Telerik team