Quantcast

Grails Cache Plugin - Support for Expiring Cache values?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Grails Cache Plugin - Support for Expiring Cache values?

jonspalmer

I’m curious about the Grails Cache plugin’s lack of support for allowing/defining how a cached value can expire. It’s a very common and powerful use case to be able to cache the results of a controller action or a service method for a certain duration. Its often the case where the application is prepared to eliminate the need to manage cache expiration at the cost of serving results from the cache that could be ‘out of date’.

 

It would seem such a common pattern that I’m surprised the cache plugin doesn’t support the ability to supply an expiration duration in the DSL/Annotations. Is there a reason that it doesn’t and if not would the work be generally interesting as a contribution?

 

Thanks,

Jon



This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails Cache Plugin - Support for Expiring Cache values?

burtbeckwith
It's not supported in general since the Spring cache API uses a lowest common denominator approach. Ehcache supports it since it is a caching implementation, so that plugin has support for it in its variant of the cache config DSL - see http://grails-plugins.github.com/grails-cache-ehcache/docs/manual/guide/usage.html#dsl

The Redis and in-memory implementations don't support it in the plugin since it's not available in the underlying implementation. If you would like to contribute that please do.

Burt

jonspalmer wrote
I'm curious about the Grails Cache plugin's lack of support for allowing/defining how a cached value can expire. It's a very common and powerful use case to be able to cache the results of a controller action or a service method for a certain duration. Its often the case where the application is prepared to eliminate the need to manage cache expiration at the cost of serving results from the cache that could be 'out of date'.

It would seem such a common pattern that I'm surprised the cache plugin doesn't support the ability to supply an expiration duration in the DSL/Annotations. Is there a reason that it doesn't and if not would the work be generally interesting as a contribution?

Thanks,
Jon



This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails Cache Plugin - Support for Expiring Cache values?

jonspalmer
Ok that makes sense. I didn't realize the ehcache implementation has its own dsl extensions. I guess the thing that confuses me is that Redis supports expiring keys so I would have thought that the grails-cache-redis plugin might have a similar DSL extension.

Jon

-----Original Message-----
From: burtbeckwith [mailto:[hidden email]]
Sent: Thursday, August 02, 2012 10:54 PM
To: [hidden email]
Subject: [grails-dev] Re: Grails Cache Plugin - Support for Expiring Cache values?

It's not supported in general since the Spring cache API uses a lowest common denominator approach. Ehcache supports it since it is a caching implementation, so that plugin has support for it in its variant of the cache config DSL - see http://grails-plugins.github.com/grails-cache-ehcache/docs/manual/guide/usage.html#dsl

The Redis and in-memory implementations don't support it in the plugin since it's not available in the underlying implementation. If you would like to contribute that please do.

Burt


jonspalmer wrote

>
> I'm curious about the Grails Cache plugin's lack of support for
> allowing/defining how a cached value can expire. It's a very common
> and powerful use case to be able to cache the results of a controller
> action or a service method for a certain duration. Its often the case
> where the application is prepared to eliminate the need to manage
> cache expiration at the cost of serving results from the cache that could be 'out of date'.
>
> It would seem such a common pattern that I'm surprised the cache
> plugin doesn't support the ability to supply an expiration duration in
> the DSL/Annotations. Is there a reason that it doesn't and if not
> would the work be generally interesting as a contribution?
>
> Thanks,
> Jon
>
>
>
> This email is intended for the person(s) to whom it is addressed and
> may contain information that is PRIVILEGED or CONFIDENTIAL. Any
> unauthorized use, distribution, copying, or disclosure by any person
> other than the
> addressee(s) is strictly prohibited. If you have received this email
> in error, please notify the sender immediately by return email and
> delete the message and any attachments from your system.
>




--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Cache-Plugin-Support-for-Expiring-Cache-values-tp4632644p4632645.html
Sent from the Grails - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails Cache Plugin - Support for Expiring Cache values?

mlawler
I wrote a "refresh-behind" cache implementation (that extends the SpringCacheService from the SpringCache plugin) for a client to help out with performance problems they were encountering (periodic application stall every 2 minutes).

In this approach, when the cache entry expires and its time to refresh it with a synchronous request/response to a backend service, you block that one particular request, but for all others you have the cache implementation serve up "stale" entries even though you are aware that the cache entry is out of date. This is useful behaviour when you cache common items that all users are likely to need access to. Because if you don't serve stale entries you will see all threads blocking on the same synchronous update of the same expired cache entry, effectively blocking the whole app while that particular entry is updated.

For some types of content, serving cached content that is stale by a few second is perfectly acceptable, and prevents these application-wide stalls every time common cache entries expire.

Let me know if you want the code for this.

On 02/08/2012, at 5:49 PM, Jon Palmer <[hidden email]> wrote:

Ok that makes sense. I didn't realize the ehcache implementation has its own dsl extensions. I guess the thing that confuses me is that Redis supports expiring keys so I would have thought that the grails-cache-redis plugin might have a similar DSL extension.

Jon

-----Original Message-----
From: burtbeckwith [mailto:burt@burtbeckwith.com]
Sent: Thursday, August 02, 2012 10:54 PM
To: [hidden email]
Subject: [grails-dev] Re: Grails Cache Plugin - Support for Expiring Cache values?

It's not supported in general since the Spring cache API uses a lowest common denominator approach. Ehcache supports it since it is a caching implementation, so that plugin has support for it in its variant of the cache config DSL - see http://grails-plugins.github.com/grails-cache-ehcache/docs/manual/guide/usage.html#dsl

The Redis and in-memory implementations don't support it in the plugin since it's not available in the underlying implementation. If you would like to contribute that please do.

Burt


jonspalmer wrote

I'm curious about the Grails Cache plugin's lack of support for
allowing/defining how a cached value can expire. It's a very common
and powerful use case to be able to cache the results of a controller
action or a service method for a certain duration. Its often the case
where the application is prepared to eliminate the need to manage
cache expiration at the cost of serving results from the cache that could be 'out of date'.

It would seem such a common pattern that I'm surprised the cache
plugin doesn't support the ability to supply an expiration duration in
the DSL/Annotations. Is there a reason that it doesn't and if not
would the work be generally interesting as a contribution?

Thanks,
Jon



This email is intended for the person(s) to whom it is addressed and
may contain information that is PRIVILEGED or CONFIDENTIAL. Any
unauthorized use, distribution, copying, or disclosure by any person
other than the
addressee(s) is strictly prohibited. If you have received this email
in error, please notify the sender immediately by return email and
delete the message and any attachments from your system.





--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Cache-Plugin-Support-for-Expiring-Cache-values-tp4632644p4632645.html
Sent from the Grails - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



regards,

Michael Lawler
Director

Office: 02 4223 0052   |   Mobile: 0411 539 876   |   Fax: 02 4225 7498   |   www.selera.com


Loading...