Skip to content

A question about expiring map #1775

Answered by ben-manes
WeeeeeeeeeeS asked this question in Q&A
Discussion options

You must be logged in to vote

In that case you would use a custom expiration policy. The expireAfterAccess means it is set on creation, insert, update, or read of the entry. Here is an example where larger guilds are given more idle time before expiration.

Cache<String, GuildInfo> guilds = Caffeine.newBuilder()
    .expireAfter(new ExpiryAfterAccess<String, GuildInfo> {
        @Override public long expireAfterCreate(String key, GuildInfo guild, long currentTime) {
          return guildDuration(guild);
        }
        @Override public long expireAfterUpdate(String key, GuildInfo guild, 
            long currentTime, long currentDuration) {
          return guildDuration(guild);
        }
        @Override public long 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants