You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hefiso <he...@gmail.com> on 2013/03/19 11:47:42 UTC

Camel cache: CamelCacheCheck and expiry on cached elements

Hi

I am using the Cache component where the elements are set to expire after,
say, 5 minutes.

However, when the component receives the operation CamelCacheCheck it does
*not* check for expiry of the element but only checks if the element
(expired or not) is in the cache before setting the header
CamelCacheElementWasFound. This happens even if i specify a very low setting
for diskExpiryThreadIntervalSeconds (say, 5 seconds).

Is this design intentionally? I would assume that the TTL of the elements
are considered when invoking CamelCacheCheck.

I have solved this "quirk" by implementing a CacheEventListener acting on
notifyElementExpired, deleting expired elements from the cache (so
CamelCacheChec works as I expected). The CacheEventListener is then added to
the eventListenerRegistry. Perhaps this quirk exists due to the way EHCache
works?

Best regards
Henrik



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-cache-CamelCacheCheck-and-expiry-on-cached-elements-tp5729404.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel cache: CamelCacheCheck and expiry on cached elements

Posted by hefiso <he...@gmail.com>.
Hi

I have created the JIRA  CAMEL-6189
<https://issues.apache.org/jira/browse/CAMEL-6189>    with a patch attached.

Best regards
Henrik




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-cache-CamelCacheCheck-and-expiry-on-cached-elements-tp5729404p5729513.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel cache: CamelCacheCheck and expiry on cached elements

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 19, 2013 at 11:47 AM, hefiso
<he...@gmail.com> wrote:
> Hi
>
> I am using the Cache component where the elements are set to expire after,
> say, 5 minutes.
>
> However, when the component receives the operation CamelCacheCheck it does
> *not* check for expiry of the element but only checks if the element
> (expired or not) is in the cache before setting the header
> CamelCacheElementWasFound. This happens even if i specify a very low setting
> for diskExpiryThreadIntervalSeconds (say, 5 seconds).
>
> Is this design intentionally? I would assume that the TTL of the elements
> are considered when invoking CamelCacheCheck.
>
> I have solved this "quirk" by implementing a CacheEventListener acting on
> notifyElementExpired, deleting expired elements from the cache (so
> CamelCacheChec works as I expected). The CacheEventListener is then added to
> the eventListenerRegistry. Perhaps this quirk exists due to the way EHCache
> works?
>

Yeah IMHO this seems reasonable that if a cache element is expired it
should not be regarded as in the cache.

As we love contributions, then fell free to log a JIRA and provide a
patch (we prefer unit tests included)
http://camel.apache.org/contributing.html

> Best regards
> Henrik
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-cache-CamelCacheCheck-and-expiry-on-cached-elements-tp5729404.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen