TimToLive/TimeToIdle kombinieren

61 views
Skip to first unread message

Uwe Hennig

unread,
Sep 22, 2016, 5:49:28 AM9/22/16
to ehcache-users
  1. EHC 3.0.1
  2. JDK 1.8. Windows 7

Gibt es eine Möglichkeit "TimeToIdle" und "TimeToLive" zu kombinieren?


        CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
               
.withCache("preConfigured",
                       
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.heap(5))
                           
.withExpiry(Expirations.timeToIdleExpiration(Duration.of(300, TimeUnit.MILLISECONDS)))
                           
.withExpiry(Expirations.timeToLiveExpiration(Duration.of(600, TimeUnit.MILLISECONDS)))
                       
)        
               
.build();        


Obiges Statement funktioniert nicht wie gewünscht.


Ich möchte dass die Objekte nach 300 Sekunden aus dem Cache geworfen werden, wenn man diese nicht abgeholt hat.

Ansonsten sollen aber die Objekte garantiert nach 600 Sekunden aus dem Cache geworfen werden.


Ist das möglich und wenn ja wie wird das konfiguriert?

Danke!

Uwe Hennig

unread,
Sep 23, 2016, 4:55:42 AM9/23/16
to ehcache-users

The question in English:
Is there a way to combine TimeToLive with TimToIdle?
The source above doesn't work for me.
I would like to have the object staying for 300 seconds "time to idle" in the cache, but after 600 seconds these objects should be definitly removed from cache.
Is this possible? How to configure this?

 

Fabien Sanglier

unread,
Sep 23, 2016, 8:38:41 AM9/23/16
to ehcach...@googlegroups.com
Hey,

 it could simply be that the timing / time unit is wrong (300ms instead of 300 seconds) since you have in your code TimeUnit.MILLISECONDS

Try changing to seconds.

Thanks

Fabien
--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-users+unsubscribe@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/907f5b40-1076-4543-853c-6173b6d12336%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Fabien Sanglier
fabiens...@gmail.com

Chris Dennis

unread,
Sep 23, 2016, 9:13:54 AM9/23/16
to ehcach...@googlegroups.com
The short answer to this is no, there is no way to combine TTI and TTL in Ehcache 3. This really comes from the fact that TTI is considered an unusual feature to have in a cache whose capacity is controlled by other mechanisms (size triggered eviction). The basic argument is spelt out here: https://github.com/ehcache/ehcache3/issues/1097 If you think you have an important counter argument to this or a usecase that is both common and requires this feature then I would encourage you to get back to us to reopen the debate on this.

Thanks,

Chris

==== Likely Lousy Google Translation ====

Die kurze Antwort auf diese nicht ist, gibt es keine Möglichkeit TTI und TTL zu kombinieren, in Ehcache 3. Dieses wirklich kommt von der Tatsache, dass TTI ist ein ungewöhnliches Merkmal betrachtet in einem Cache, deren Kapazität zu haben, wird durch andere Mechanismen gesteuert (Größe ausgelöst Räumung ). Das Hauptargument ist hier buchstabiert: https://github.com/ehcache/ehcache3/issues/1097 Wenn Sie denken, Sie haben einen wichtigen Gegenargument zu dieser oder einer usecase, die beide gemeinsam ist, und erfordert diese Funktion dann würde ich Sie ermutigen, Sie zu uns zurück, um die Debatte über diese wieder zu öffnen.

Vielen Dank,

Chris
> To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
> To post to this group, send email to ehcach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/907f5b40-1076-4543-853c-6173b6d12336%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Fabien Sanglier
> fabiens...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups "ehcache-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
> To post to this group, send email to ehcach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/CAOEjUMig3vMVKAr4HKOgS-KJJb3q7St-KhnZ%3D%2BKOpUZjTXWHdg%40mail.gmail.com.

Uwe Hennig

unread,
Sep 23, 2016, 10:43:14 AM9/23/16
to ehcache-users
Thanks for the answer.

Let me give an example of my use case. My customer reads big data (pictures) from an external system.
I do not want to update or download this data, because it took too much time. I do not want to hold this data to long in my cache (memory).

The client wants to work with this data until he has done his work - "idle time".
But I do not want the client to work with too old data. For that reason I have to do an update after a while.
The TTL will drop old data from cache and the client can decide to download and refresh the data again.

Yes, I can do an update programmatically, but a combination of TTL and TTI will solve my problem without any effort.

For example:
TTI = 15 minutes. Average retention time 30 minutes.
TTL = 1 hour. Maximum retention time 1 hour.
Reply all
Reply to author
Forward
0 new messages