This is a migrated thread and some comments may be shown as answers.

L2 Cache

13 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
john
Top achievements
Rank 1
john asked on 28 Nov 2012, 07:48 AM
Can explain L2 Cache is used under which scenario?

13 Answers, 1 is accepted

Sort by
0
Doroteya
Telerik team
answered on 29 Nov 2012, 09:47 AM
Hello John,

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
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
0
john
Top achievements
Rank 1
answered on 29 Nov 2012, 12:34 PM
For example I enable the L2 Cache. In search page, I click search button and it will call DB to get data with OpenAccess ORM. Then another user modify one record which is in search result. At this time, if I try to click search button with same parameter, whether it will not get the updated data?
0
Ady
Telerik team
answered on 04 Dec 2012, 11:19 AM
Hi Jin Zhi Hao,

 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
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
0
john
Top achievements
Rank 1
answered on 12 Dec 2012, 02:33 PM
If my application is a distributed application, whethether the L2 cache will be synchronized in mutipule app servers?
0
Ady
Telerik team
answered on 13 Dec 2012, 09:23 AM
Hello Jin Zhi Hao,

 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
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
0
john
Top achievements
Rank 1
answered on 20 Dec 2012, 08:16 AM
Hi,

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?
0
Ralph Waldenmaier
Telerik team
answered on 20 Dec 2012, 09:50 AM
Hello Jin Zhi Hao,

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.

Kind regards,
Ralph
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
0
john
Top achievements
Rank 1
answered on 20 Dec 2012, 02:14 PM
The cache is store in DB server or app server? Also, whether the cache is stored in memory?
0
Ralph Waldenmaier
Telerik team
answered on 20 Dec 2012, 02:43 PM
Hi Jin Zhi Hao,

The cache is stored in the memory of your application.
 
Feel free to ask if you have any other question.

Kind regards,
Ralph
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
john
Top achievements
Rank 1
answered on 23 Dec 2012, 01:06 PM
The cache is stored in DB server or app server?
0
Viktor Zhivkov
Telerik team
answered on 26 Dec 2012, 01:59 PM
Hi Jin,

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
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
john
Top achievements
Rank 1
answered on 27 Dec 2012, 05:14 AM
1.“It is available to all callers only in the application domain of the first data context query”, Whether it means that the cache is available after the first data context query is called, then it will put the data into cache?

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?
0
Dimitar Tachev
Telerik team
answered on 28 Dec 2012, 08:44 AM
Hi John,

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.

Regards,
Dimitar Tachev
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Tags
General Discussions
Asked by
john
Top achievements
Rank 1
Answers by
Doroteya
Telerik team
john
Top achievements
Rank 1
Ady
Telerik team
Ralph Waldenmaier
Telerik team
Viktor Zhivkov
Telerik team
Dimitar Tachev
Telerik team
Share this question
or