When use both expireAfterAccess and expireAfterWrite options

101 views
Skip to first unread message

bokman

unread,
Jan 2, 2023, 11:55:51 PM1/2/23
to guava-discuss
Hi All. Happy new year

when I use both option. I think the result is strange. Can you explain the internal logic when this happens?

테스트.PNG

first, if I use expireAfterWrite and expireAfterAccess both. how it will be expired. follow AfterWrite? or AfterAccess?

테스트결과.PNG
The results show that it behaves like expireAfterWrite, but Why didn't key1 come out when it was 0 seconds?

when I use just expireAfterWrite

write5.PNG
write5result.PNG

I want to understand underlying logic

Please understand that my English is not good

Ben Manes

unread,
Jan 5, 2023, 2:03:13 PM1/5/23
to bokman, guava-discuss
It was likely a mistake to allow both expiration settings to be used at once. These are two independent durations, so the shortest will always take precedence. Generally when both are set then expireAfterWrite is what the user wanted and will observe. I don't recall ever seeing a valid reason when both were set.

To better control time in a unit test then you can use FakeTicker (from testlib) and if you believe there is a bug then please file an issue with the failing test. 

--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss
 
This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/3c59f679-6795-445e-87f1-6bc292639c61n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages