You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ferry Syafei Sapei <fe...@googlemail.com> on 2016/07/05 11:23:50 UTC

Expiry cache at a certain time

Hi all,

Would it be possible to implement a custom expiry policy to expire cache content at a certain time, e.g.: at 12:00 all the cache contents will be expired and removed from the cache?

Thanks.


Best regards,
fsapei

Re: Expiry cache at a certain time

Posted by Vladislav Pyatkov <vl...@gmail.com>.
By javadoc for javax.cache.expiry.ExpiryPolicy[1].

Returning <code>null</code> will result in no change to the previously
understood expiry {@link Duration}.

If you implement method
(javax.cache.expiry.ExpiryPolicy#getExpiryForCreation) and return null in
an other (getExpiryForAccess, getExpiryForUpdate) you no have reason to
recalculation duration each time when update or access to value by same key.

Duration assign to Cache.Entry (key - value pair) on create and bound to
Entry (if other methods of ExpiryPolicy return null).

[1]:
http://static.javadoc.io/javax.cache/cache-api/1.0.0/javax/cache/expiry/ExpiryPolicy.html

On Tue, Jul 5, 2016 at 4:06 PM, Ferry Syafei Sapei <
ferry.sapei@googlemail.com> wrote:

> Thank you for your answer.
>
> Let’s say that I put a cache entry with key „x“ and value 1 at 10:00. If I
> continuously increment the entry „x“ by one every minute, I must calculate
> the duration from current time to 12:00 each time I update the entry in the
> cache. Is it correct?
>
>
> Am 05.07.2016 um 14:55 schrieb Vladislav Pyatkov <vl...@gmail.com>:
>
> Hello,
>
> You can implement yourself expiration policy
> (javax.cache.expiry.ExpiryPolicy) like it done in
> javax.cache.expiry.CreatedExpiryPolicy. In your case you need to calculate
> duration from current time to 12:00 in the mach method
> (javax.cache.expiry.CreatedExpiryPolicy#getExpiryForCreation).
>
> Also you can look into the topic about how to expiration policy is
> using[1].
>
> [1]: https://apacheignite.readme.io/docs/expiry-policies
>
> On Tue, Jul 5, 2016 at 2:23 PM, Ferry Syafei Sapei <
> ferry.sapei@googlemail.com> wrote:
>
>> Hi all,
>>
>> Would it be possible to implement a custom expiry policy to expire cache
>> content at a certain time, e.g.: at 12:00 all the cache contents will be
>> expired and removed from the cache?
>>
>> Thanks.
>>
>>
>> Best regards,
>> fsapei
>
>
>
>
> --
> Vladislav Pyatkov
>
>
>


-- 
Vladislav Pyatkov

Re: Expiry cache at a certain time

Posted by Ferry Syafei Sapei <fe...@googlemail.com>.
Thank you for your answer.

Let’s say that I put a cache entry with key „x“ and value 1 at 10:00. If I continuously increment the entry „x“ by one every minute, I must calculate the duration from current time to 12:00 each time I update the entry in the cache. Is it correct?


> Am 05.07.2016 um 14:55 schrieb Vladislav Pyatkov <vl...@gmail.com>:
> 
> Hello,
> 
> You can implement yourself expiration policy (javax.cache.expiry.ExpiryPolicy) like it done in javax.cache.expiry.CreatedExpiryPolicy. In your case you need to calculate duration from current time to 12:00 in the mach method (javax.cache.expiry.CreatedExpiryPolicy#getExpiryForCreation).
> 
> Also you can look into the topic about how to expiration policy is using[1].
> 
> [1]: https://apacheignite.readme.io/docs/expiry-policies <https://apacheignite.readme.io/docs/expiry-policies>
> 
> On Tue, Jul 5, 2016 at 2:23 PM, Ferry Syafei Sapei <ferry.sapei@googlemail.com <ma...@googlemail.com>> wrote:
> Hi all,
> 
> Would it be possible to implement a custom expiry policy to expire cache content at a certain time, e.g.: at 12:00 all the cache contents will be expired and removed from the cache?
> 
> Thanks.
> 
> 
> Best regards,
> fsapei
> 
> 
> 
> -- 
> Vladislav Pyatkov


Re: Expiry cache at a certain time

Posted by Vladislav Pyatkov <vl...@gmail.com>.
Hello,

You can implement yourself expiration policy
(javax.cache.expiry.ExpiryPolicy) like it done in
javax.cache.expiry.CreatedExpiryPolicy. In your case you need to calculate
duration from current time to 12:00 in the mach method
(javax.cache.expiry.CreatedExpiryPolicy#getExpiryForCreation).

Also you can look into the topic about how to expiration policy is using[1].

[1]: https://apacheignite.readme.io/docs/expiry-policies

On Tue, Jul 5, 2016 at 2:23 PM, Ferry Syafei Sapei <
ferry.sapei@googlemail.com> wrote:

> Hi all,
>
> Would it be possible to implement a custom expiry policy to expire cache
> content at a certain time, e.g.: at 12:00 all the cache contents will be
> expired and removed from the cache?
>
> Thanks.
>
>
> Best regards,
> fsapei




-- 
Vladislav Pyatkov