You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by GESCONSULTOR - Óscar Bou <o....@gesconsultor.com> on 2015/07/08 19:24:03 UTC

Re: Caching Actions by simply using an annotation (param)

Hi, Dan.

I’ve just pushed a new PR to Github (ISIS-1157) where I’m started to implement this [1].

As I wanted to not duplicate the implementation currently on the QueryResultsCache service, you will notice I’ve created a new Facet implementation on the “runtime” module.

Please, can you review it?

Thanks,

Oscar

[1] https://github.com/apache/isis/pull/32 <https://github.com/apache/isis/pull/32>




> El 5/6/2015, a las 15:35, GESCONSULTOR - Óscar Bou <o....@gesconsultor.com> escribió:
> 
> Hi, Dan.
> 
> I’m planning on implement this.
> 
> I’ve just created a Jira ticket [1].
> 
> Please, can you review and comment my implementation proposal?
> 
> Thanks!
> 
> Oscar
> 
> [1] https://issues.apache.org/jira/browse/ISIS-1157 <https://issues.apache.org/jira/browse/ISIS-1157>
> 
> 
> 
> 
> 
>> El 10/5/2015, a las 17:25, GESCONSULTOR <o.bou@gesconsultor.com <ma...@gesconsultor.com>> escribió:
>> 
>> 
>> Let me try it! 
>> 
>> I'll not been able to implement it immediately but please, tell me the hints :)
>> 
>> 
>> 
>> 
>> 
>> El 10/5/2015, a las 13:25, Dan Haywood <dan@haywood-associates.co.uk <ma...@haywood-associates.co.uk>> escribió:
>> 
>>> Hi Oscar,
>>> 
>>> yes, this makes a lot of sense, and is something I've thought about in the past myself (though I don't think it's been discussed on the mailing list before).
>>> 
>>> In terms of API, it only really makes sense to enable caching for safe (query-only) actions.  So I suggest that it might be better to extend the ActionSemantics enum:
>>> 
>>> 
>>>     @Override
>>>     @Action(semantics = SemanticsOf.SAFE_AND_REQUEST_CACHED)
>>>     public SortedSet<IESG> relevantSnpGenotypes(final IE inputElement,
>>>             final Kit kit) {
>>>         if (kit != null) {
>>>             return kit.findAllAssociatedSNPGenotypesForInputElement(inputElement, AlgorithmImplementation.this.IESGClass);
>>>         } else {
>>>             return Sets.newTreeSet();
>>>         }
>>>     }
>>> 
>>> 
>>> I suggest the word "REQUEST" is in the enum somewhere just so it's obvious that the caching is only for the duration of a request (rather than session or something else).
>>> 
>>> This feature is probably pretty easy to implement.  I can do it if you want, but if you'd like to give it a go I can provide some pointers if you want?
>>> 
>>> cheers
>>> Dan
>>> 
>>> 
>>> 
>>> 
>>> On 10 May 2015 at 12:14, GESCONSULTOR - Óscar Bou <o.bou@gesconsultor.com <ma...@gesconsultor.com>> wrote:
>>> 
>>> 
>>> Hi all.
>>> 
>>> We currently have available the "org.apache.isis.applib.services.queryresultscache.QueryResultsCache” service to cache the result of an Action invocation for the  same transation.
>>> 
>>> So if we call a SAFE action that is costly to be computed, many times during the same transaction, it’s only computed once, as the 2nd time and so on the result will be obtained from a LocalThread cache.
>>> 
>>> Current usage idiom is something like:
>>> 
>>>     // {{ relevantSnpGenotypes (programmatic - cached)
>>>     @Override
>>>     @Action(semantics = SemanticsOf.SAFE)
>>>     public SortedSet<IESG> relevantSnpGenotypes(final IE inputElement,
>>>             final Kit kit) {
>>>         return this.queryResultsCache.execute(new Callable<SortedSet<IESG>>() {
>>> 
>>>             @Override
>>>             public SortedSet<IESG> call() throws Exception {
>>>                 if (kit != null) {
>>>                     return kit.findAllAssociatedSNPGenotypesForInputElement(inputElement, AlgorithmImplementation.this.IESGClass);
>>>                 } else {
>>>                     return Sets.newTreeSet();
>>>                 }
>>>             }
>>> 
>>>         }, Kit.class, "relevantSnpGenotypes", inputElement, kit);
>>>     }
>>> 
>>>     // }}
>>> 
>>> 
>>>     // {{ injected: QueryResultsCache
>>>     @Inject
>>>     protected QueryResultsCache queryResultsCache;
>>> 
>>>     // }}
>>> 
>>> 
>>> 
>>> But perhaps would it be possible to ease its usage by means of an annotation ?
>>> 
>>> Something like:
>>> 
>>> 
>>>     @Action(semantics = SemanticsOf.SAFE, cacheResults = true)
>>> 
>>> 
>>> If so, the usage idiom would change to simply the action’s code, as the one responsible for caching could be a Facet, for example?
>>> 
>>>     // {{ relevantSnpGenotypes (programmatic - cached)
>>>     @Override
>>>     @Action(semantics = SemanticsOf.SAFE, cacheResults = true)
>>>     public SortedSet<IESG> relevantSnpGenotypes(final IE inputElement,
>>>             final Kit kit) {
>>>         if (kit != null) {
>>>             return kit.findAllAssociatedSNPGenotypesForInputElement(inputElement, AlgorithmImplementation.this.IESGClass);
>>>         } else {
>>>             return Sets.newTreeSet();
>>>         }
>>>     }
>>> 
>>>     // }}
>>> 
>>> 
>>> Just to know others opinion about if it has sense and if it would be possible.
>>> 
>>> I’m pretty sure this would be one of those “killer functions” for complex Domains that would appear on a summary list, despite being currently being available.
>>> 
>>> 
>>> 
>>> Thanks!
>>> 
>>> 
>>> 
>>> Óscar Bou Bou
>>> Responsable de Producto
>>> Auditor Jefe de Certificación ISO 27001 en BSI
>>> CISA, CRISC, APMG ISO 20000, ITIL-F
>>> 
>>> <contactenos.html.gif>   902 900 231 / 620 267 520
>>> <Pasted Graphic 1.tiff>   http://www.twitter.com/oscarbou <http://www.twitter.com/oscarbou>
>>> 
>>> <gesdatos-software.gif>   http://es.linkedin.com/in/oscarbou <http://es.linkedin.com/in/oscarbou>
>>> 
>>> <blog.png>   http://www.GesConsultor.com <http://www.gesconsultor.com/> 
>>> 
>>> <gesconsultor_logo_blue_email.png>
>>> 
>>> 
>>> Este mensaje y los ficheros anexos son confidenciales. Los mismos contienen información reservada que no puede ser difundida. Si usted ha recibido este correo por error, tenga la amabilidad de eliminarlo de su sistema y avisar al remitente mediante reenvío a su dirección electrónica; no deberá copiar el mensaje ni divulgar su contenido a ninguna persona.
>>> Su dirección de correo electrónico junto a sus datos personales constan en un fichero titularidad de Gesdatos Software, S.L. cuya finalidad es la de mantener el contacto con Ud. Si quiere saber de qué información disponemos de Ud., modificarla, y en su caso, cancelarla, puede hacerlo enviando un escrito al efecto, acompañado de una fotocopia de su D.N.I. a la siguiente dirección: Gesdatos Software, S.L. , Paseo de la Castellana, 153 bajo - 28046 (Madrid), y Avda. Cortes Valencianas num. 50, 1ºC - 46015 (Valencia). Asimismo, es su responsabilidad comprobar que este mensaje o sus archivos adjuntos no contengan virus informáticos, y en caso que los tuvieran eliminarlos.
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
> 
> 
> Óscar Bou Bou
> Responsable de Producto
> Auditor Jefe de Certificación ISO 27001 en BSI
> CISA, CRISC, APMG ISO 20000, ITIL-F
> 
> <contactenos.html.gif>   902 900 231 / 620 267 520
> <Pasted Graphic 1.tiff>   http://www.twitter.com/oscarbou <http://www.twitter.com/oscarbou>
> 
> <gesdatos-software.gif>   http://es.linkedin.com/in/oscarbou <http://es.linkedin.com/in/oscarbou>
> 
> <blog.png>   http://www.GesConsultor.com <http://www.gesconsultor.com/> 
> 
> <gesconsultor_logo_blue_email.png>
> 
> 
> Este mensaje y los ficheros anexos son confidenciales. Los mismos contienen información reservada que no puede ser difundida. Si usted ha recibido este correo por error, tenga la amabilidad de eliminarlo de su sistema y avisar al remitente mediante reenvío a su dirección electrónica; no deberá copiar el mensaje ni divulgar su contenido a ninguna persona.
> Su dirección de correo electrónico junto a sus datos personales constan en un fichero titularidad de Gesdatos Software, S.L. cuya finalidad es la de mantener el contacto con Ud. Si quiere saber de qué información disponemos de Ud., modificarla, y en su caso, cancelarla, puede hacerlo enviando un escrito al efecto, acompañado de una fotocopia de su D.N.I. a la siguiente dirección: Gesdatos Software, S.L. , Paseo de la Castellana, 153 bajo - 28046 (Madrid), y Avda. Cortes Valencianas num. 50, 1ºC - 46015 (Valencia). Asimismo, es su responsabilidad comprobar que este mensaje o sus archivos adjuntos no contengan virus informáticos, y en caso que los tuvieran eliminarlos.


Óscar Bou Bou
Responsable de Producto
Auditor Jefe de Certificación ISO 27001 en BSI
CISA, CRISC, APMG ISO 20000, ITIL-F

   902 900 231 / 620 267 520
   http://www.twitter.com/oscarbou <http://www.twitter.com/oscarbou>

   http://es.linkedin.com/in/oscarbou <http://es.linkedin.com/in/oscarbou>

   http://www.GesConsultor.com <http://www.gesconsultor.com/> 




Este mensaje y los ficheros anexos son confidenciales. Los mismos contienen información reservada que no puede ser difundida. Si usted ha recibido este correo por error, tenga la amabilidad de eliminarlo de su sistema y avisar al remitente mediante reenvío a su dirección electrónica; no deberá copiar el mensaje ni divulgar su contenido a ninguna persona.
Su dirección de correo electrónico junto a sus datos personales constan en un fichero titularidad de Gesdatos Software, S.L. cuya finalidad es la de mantener el contacto con Ud. Si quiere saber de qué información disponemos de Ud., modificarla, y en su caso, cancelarla, puede hacerlo enviando un escrito al efecto, acompañado de una fotocopia de su D.N.I. a la siguiente dirección: Gesdatos Software, S.L. , Paseo de la Castellana, 153 bajo - 28046 (Madrid), y Avda. Cortes Valencianas num. 50, 1ºC - 46015 (Valencia). Asimismo, es su responsabilidad comprobar que este mensaje o sus archivos adjuntos no contengan virus informáticos, y en caso que los tuvieran eliminarlos.