New Posts New Posts RSS Feed: Selectively Remove queries from QueryCache
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Selectively Remove queries from QueryCache

 Post Reply Post Reply
Author
myr_zero View Drop Down
Newbie
Newbie
Avatar

Joined: 11-Mar-2013
Location: India
Posts: 15
Post Options Post Options   Quote myr_zero Quote  Post ReplyReply Direct Link To This Post Topic: Selectively Remove queries from QueryCache
    Posted: 03-Apr-2013 at 11:49pm
Hey mgood

Thanks for your suggestions. That's a very nice documentation there.

In my case the whole idea behind using a common EntityManager for the application is "better performance".

When the same page is revisited, we don't want to load all the data again from database. If we make use of cache, then we save lot of time.

But in other way, we don't want to keep the outdated entities in cache. It is possible that some thing might have been updated in database from some other client. So at certain intervals we want to remove SPECIFIC(not all) entities from cache, so that we get latest to show when queried for. And also we don't want to occupy more memory with more data. That is the other reason we want to clear some entities at regular intervals.

Using a different entity manager for each unit of code won't give the advantage of loading from cache when it is revisited. If all separate EntityManagers are made to persist for the life time of application then again comes the problem with memory consumption.

So if QueryCache.Remove is working properly or RemoveEntity method automatically handles removing of only related queries from query cache, then it would solve problem of all developers who want to take care memory.


Thanks
Manju
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 02-Apr-2013 at 11:42pm
Manju,
It sounds like your rather large application is using a single EntityManager for everything. That's fine for a small application, but a large application should be broken up into units of work, each one using its own EntityManager. For commonly used entities a second level cache approach can be utilized. You may wanna take a look at our reference application where you can see this in action. There is a series of videos that walk you through the code etc.



Edited by mgood - 02-Apr-2013 at 11:55pm
Back to Top
myr_zero View Drop Down
Newbie
Newbie
Avatar

Joined: 11-Mar-2013
Location: India
Posts: 15
Post Options Post Options   Quote myr_zero Quote  Post ReplyReply Direct Link To This Post Posted: 02-Apr-2013 at 8:51pm
Hi

We are using Optimized QueryStrategy. So when the same query is called again we want to make use of Cache. But as the number of queries getting executed increases, number of queries in QueryCache and hence number of entities in EntityCache will also increase. 

Some of the queries, entities which were called in the start of the application will remain in the cache for the life time of application even though they are not used anymore. we want to remove those entities and queries from Cache.

And also some of the entities which were not accessed since a specific time duration, need to be removed/refreshed.

The purpose of this is to optimized utilization of memory. We have large database with lots of entities. We don't want to pile up memory with a large Cache. At the same time we don't want to miss the advantage of using cache for better performance.

This is the reason to go for manual management of Cache.

If you can suggest any alternative or any such implementation already provided by DevForce which we are not aware, then it would be really helpful for us.


Thanks
Manju
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 01-Apr-2013 at 10:40am
myr-zero,

We don't have an estimated date for this fix.

I'd suggest relying on DevForce to manage the QueryCache.

Note that since manually managing the QueryCache is not very common and DevForce manages it properly, this issue ranks lowers in our priority list.

Kind regards.
Back to Top
myr_zero View Drop Down
Newbie
Newbie
Avatar

Joined: 11-Mar-2013
Location: India
Posts: 15
Post Options Post Options   Quote myr_zero Quote  Post ReplyReply Direct Link To This Post Posted: 26-Mar-2013 at 6:18pm
Oops!! That is bad news for me.

Even I tried with EntityKey as parameter to QueryCache.Remove method. This is not working too.

Is there estimated time on when the fix for this bug be available?

Thanks you
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 26-Mar-2013 at 10:49am
Hi myr_zero,

I was able to reproduce the issue. I am filing a bug and will let you know once we have a fix.
Back to Top
myr_zero View Drop Down
Newbie
Newbie
Avatar

Joined: 11-Mar-2013
Location: India
Posts: 15
Post Options Post Options   Quote myr_zero Quote  Post ReplyReply Direct Link To This Post Posted: 25-Mar-2013 at 7:07pm
Hi

I am trying to write code to manually manage EntityManager cache. I have code which gives me the list of entities which needs to be removed from the EntityCache.

What I want to do is remove the entity form EntityCache and remove related queries from QueryCache.

DevForce provide method RemoveEntity which takes two parameters. First parameter is entity and second parameter is flag to clear query cache. If I do not provide second parameter or provide it as true, then DevForce clears the whole QueryCache, not just the queries related to the entity being removed. This is not solution for me since I dont want to remove all the queries.

So I decided on using QueryCache.Remove method. This method comes with three signatures. Two of which use EntityKey. I dont have entity key with me now. So I have to use the other method which use Entity Type.

I use it like this

entityManager.QueryCache.Remove(entity.GetType())

But this seems to be not doing the work. I can still see the same queries present in the QueryCache. A query which uses the specified type of entity is not removed from the query cache.

Any help in this would be appreciated


Thanks
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down