jhalterman / expiringmap

A high performance thread-safe map that expires entries
Apache License 2.0
1.01k stars 142 forks source link

Is it possible never expired in Variable Expiration Map? #41

Open deanwong opened 7 years ago

deanwong commented 7 years ago

when I use put(K key, V value) the default expiration time is 1 min.

jhalterman commented 7 years ago

ExpiringMap always wants to expire things, thus the name :)

The best you can do is set expiration to be something very far off: such as Integer.MAX_VALUE TimeUnit.DAYS.

buderjoh commented 5 years ago

Is it possible to use -1? In this case it should not expire at all right?

jhalterman commented 5 years ago

Is your use case trying to mix things that should never expire with things that do in the same map? Currently there's no way to indicate that an entry should never expire, but I'd be happy to take a PR that allows negative values to indicate an entry should not expire.

If someone is up for this, this would and should only work with dynamic expiration though, else the put should be rejected with IllegalArgumentException.