How to refresh a model cache when an external resource changes? [message #904820] |
Wed, 29 August 2012 04:03  |
Eclipse User |
|
|
|
I keep a cache of expensive values in my code which is attached to the model:
public static ValidationCache getValidationCache( EObject obj ) {
final XtextResource res = (XtextResource) obj.eResource();
final I18nDomainModel model = getModel( obj );
return res.getCache().get( ValidationCache.class.getName(), res, new Provider<ValidationCache>() {
@Override
public ValidationCache get() {
// log.debug( "New cache for " + res );
return new ValidationCache( model );
}
} );
}
This works pretty well. Now I have an external resource with some options. For the sake of the question, let's say I have this:
model.i18n <-- Xtext resource
model.config <-- Additional resource
I need to flush the cache when model.config is updated. How can I do that?
Regards,
A. Digulla
|
|
|
|
|
Re: How to refresh a model cache when an external resource changes? [message #905428 is a reply to message #904820] |
Thu, 30 August 2012 07:13   |
Eclipse User |
|
|
|
Hi Aaron,
please make sure that IResourceDescription.Manager returns true on the
#isAffected query as soon as the dependent resource changes
significantly for your caching mechanism.
If that does not work for you for some reason, you'll most likely have
to implement that in your ValidationCache. Btw: Which sort of
information do you store in that cache. Is that something that should be
user data in the resource description itself?
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 29.08.12 10:03, schrieb Aaron Digulla:
> I keep a cache of expensive values in my code which is attached to the
> model:
>
>
> public static ValidationCache getValidationCache( EObject obj ) {
> final XtextResource res = (XtextResource) obj.eResource();
> final I18nDomainModel model = getModel( obj );
> return res.getCache().get( ValidationCache.class.getName(), res,
> new Provider<ValidationCache>() {
> @Override
> public ValidationCache get() {
> // log.debug( "New cache for " + res );
> return new ValidationCache( model );
> }
> } );
> }
>
>
> This works pretty well. Now I have an external resource with some
> options. For the sake of the question, let's say I have this:
>
>
> model.i18n <-- Xtext resource
> model.config <-- Additional resource
>
>
> I need to flush the cache when model.config is updated. How can I do that?
>
> Regards,
>
> A. Digulla
|
|
|
|
Re: How to refresh a model cache when an external resource changes? [message #1047562 is a reply to message #904982] |
Tue, 23 April 2013 07:36  |
Eclipse User |
|
|
|
Hi Henrik,
It would be helpful if you could point to the place in your code where you manually trigger a new build of everything.
Thanks again,
Chris
Henrik Lindberg wrote on Wed, 29 August 2012 23:08On 2012-29-08 10:03, Aaron Digulla wrote:
>
> I need to flush the cache when model.config is updated. How can I do that?
>
I do something similar when validation preferences are changed in
Geppetto - I just trigger a new build of everything (in my case anything
could be affected by the change).
Is that what you want to do? Can point you to my code.
- henrik
|
|
|
Powered by
FUDForum. Page generated in 0.04924 seconds