Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Evicting cache based on a particular element value being modified(Customized Caching)
Evicting cache based on a particular element value being modified [message #1238706] Sun, 02 February 2014 05:24 Go to next message
Anil Bhatia is currently offline Anil BhatiaFriend
Messages: 23
Registered: February 2011
Junior Member
I also noticed behavior similar to what is mentioned here http://www.eclipse.org/forums/index.php/mv/msg/639125/1233703/#msg_1233703


In my scenario, I have a higher level model element (close to the root, and this element is populated only once by the user, it does not occur again in the model).

Based upon the populated value, I have to do some expensive computation in scope provider, to customize the scope for some lower level elements.

I want to put the result of computation into cache, and redo the computation only when user comes back to this element, and changes its value.

Isn't there a way to tie eviction of a cache entry with a particular model element, saying - do not evict this cache entry, unless this model element value is modified, irrespective of whether the call is from inferrer, validator, or label provider...?
Re: Evicting cache based on a particular element value being modified [message #1241766 is a reply to message #1238706] Sat, 08 February 2014 13:31 Go to previous messageGo to next message
Anil Bhatia is currently offline Anil BhatiaFriend
Messages: 23
Registered: February 2011
Junior Member
Since nobody responded, sorry if my question was absurd...
But going by the number of views this question has, I assume lot of people might be interested in the answer....

I tried solving this problem by using OnChangeEvictingCache#execWithoutCacheClear, by providing IUnitOfWork#exec, and returning instance of object I want to cache from exec.
That did not seem to help at all.

I am willing to try if there are any more options.
Alternatively, can someone point me to any documentation on how to implement custom caching.

Thanks
Anil
Re: Evicting cache based on a particular element value being modified [message #1241786 is a reply to message #1241766] Sat, 08 February 2014 14:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Why do you want to cache at all maybe you can achieve it on another
way.

I don't know any docs on how to implement the cache yourself

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Evicting cache based on a particular element value being modified [message #1241860 is a reply to message #1241786] Sat, 08 February 2014 17:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
btw did you try to simply overwrite org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter.clearValues()

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Evicting cache based on a particular element value being modified [message #1241896 is a reply to message #1241860] Sat, 08 February 2014 18:23 Go to previous messageGo to next message
Anil Bhatia is currently offline Anil BhatiaFriend
Messages: 23
Registered: February 2011
Junior Member
Overriding org.eclipse.xtext.util.OnChangeEvictingCache.CacheAdapter.clearValues() is surely a good idea.
So, for that do I need to override org.eclipse.xtext.util.OnChangeEvictingCache.getOrCreate(Resource)..? if yes (or no), how..?

Thanks
Anil
Re: Evicting cache based on a particular element value being modified [message #1241906 is a reply to message #1241896] Sat, 08 February 2014 18:43 Go to previous messageGo to next message
Anil Bhatia is currently offline Anil BhatiaFriend
Messages: 23
Registered: February 2011
Junior Member
What I really mean to ask is - how do I bind my implementation so that it gets invoked..? I am using @Inject to get instance of cache as follows in my ScopeProvider:

@Inject
private OnChangeEvictingCache cache;
Re: Evicting cache based on a particular element value being modified [message #1241921 is a reply to message #1241906] Sat, 08 February 2014 19:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
what about directly using your class there?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Evicting cache based on a particular element value being modified [message #1241926 is a reply to message #1241921] Sat, 08 February 2014 19:29 Go to previous messageGo to next message
Anil Bhatia is currently offline Anil BhatiaFriend
Messages: 23
Registered: February 2011
Junior Member
Seems to work just the way I wanted. Thanks a lot for the simple hint Christian.

So now my overridden implementation of clearValues() is just empty. I guess, that means this cache is never evicted.
I hope that does not lead to memory leakage (or built up). Can you please clarify..?

Thanks
Anil
Re: Evicting cache based on a particular element value being modified [message #1241936 is a reply to message #1241926] Sat, 08 February 2014 19:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hmmm i dont know that... but i actually wanted you to check for a change there....

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Evicting cache based on a particular element value being modified [message #1242495 is a reply to message #1241936] Sun, 09 February 2014 17:19 Go to previous message
Anil Bhatia is currently offline Anil BhatiaFriend
Messages: 23
Registered: February 2011
Junior Member
Thanks for the hint, Christian.
I will surely try this out, and get back.

Thanks
Anil
Previous Topic:OutputConfigurationProvider with empty output-directory
Next Topic: EMF Editor Runtime Exception
Goto Forum:
  


Current Time: Tue Apr 23 14:20:49 GMT 2024

Powered by FUDForum. Page generated in 0.03798 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top