[infinispan-issues] [JBoss JIRA] (ISPN-5801) Cache with CacheLoader and CreatedExpiryPolicy Invalidates Instantly
Dan Siviter (JIRA)
issues at jboss.org
Thu Oct 1 07:03:00 EDT 2015
[ https://issues.jboss.org/browse/ISPN-5801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13114107#comment-13114107 ]
Dan Siviter edited comment on ISPN-5801 at 10/1/15 7:02 AM:
------------------------------------------------------------
So looking at the code comments in {{JCacheInternalMetadata}} it states {{#expiry}} is:
bq. // absolute time when entry should expire
However, if {{CreatedExpiryPolicy}} is set to {{Duration#FIVE_MINUTES}} this value will be 300,000ms. This causes {{JCacheInternalMetadata#isExpired}} to return {{true}}. Personally, I'd say that {{#expiry}} should be the offset and not absolute time. Therefore, the issue could be fixed using:
{code}
@Override
public boolean isExpired(long now) {
return expiry > -1 && (created + expiry) <= now;
}
{code}
...but I'm not sure of the impact of this.
was (Author: dan_siviter):
So looking at the code comments in {{JCacheInternalMetadata}} it states {{#expiry}} is:
bq. // absolute time when entry should expire
However, if {{CreatedExpiryPolicy}} is set to {{Duration#FIVE_MINUTES}} this value will be 300,000ms. This causes {{JCacheInternalMetadata#isExpired}} to return the incorrect value. Personally, I'd say that {{#expiry}} should be the offset and not absolute time. Therefore, the issue could be fixed using:
{code}
@Override
public boolean isExpired(long now) {
return expiry > -1 && (created + expiry) <= now;
}
{code}
...but I'm not sure of the impact of this.
> Cache with CacheLoader and CreatedExpiryPolicy Invalidates Instantly
> --------------------------------------------------------------------
>
> Key: ISPN-5801
> URL: https://issues.jboss.org/browse/ISPN-5801
> Project: Infinispan
> Issue Type: Bug
> Components: JCache
> Affects Versions: 8.0.1.Final
> Reporter: Dan Siviter
>
> When using a {{javax.cache.expiry.CreatedExpiryPolicy}} and a {{javax.cache.integration.CacheLoader}} the value generated for the {{org.infinispan.jcache.embedded/JCacheInternalMetadata#expiry}} is not relative to {{TimeService#wallClockTime}}. It therefore invalidates the entry instantly.
> I believe the problem is in {{org.infinispan.jcache.embedded.JCacheLoaderAdapter\[line=48\]}} where {{org.infinispan.jcache.Expiration#getExpiry(...)}} doesn't calculate the relative value so {{org.infinispan.jcache.embedded.JCacheInternalMetadata#isExpired}} always returns {{true}}.
> Unfortunately, work doesn't allow me to upload code so I can't submit an example.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the infinispan-issues
mailing list