Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put the same key with different ttl #76

Open
zysaaa opened this issue Nov 28, 2021 · 2 comments
Open

Put the same key with different ttl #76

zysaaa opened this issue Nov 28, 2021 · 2 comments

Comments

@zysaaa
Copy link

zysaaa commented Nov 28, 2021

        expiringMap.put("a", "a", 1000, TimeUnit.MILLISECONDS);
        expiringMap.put("a", "a", 20_000, TimeUnit.MILLISECONDS);
        Thread.sleep(5000);
        System.out.println(expiringMap.get("a")); // output null

Is this expected behavior? Can't I refresh ttl of this key?

@littleQiu22
Copy link

Try this:

expiringMap.put("a", "a", 1000, TimeUnit.MILLISECONDS);
expiringMap.setExpiration("a", 20_000, TimeUnit.MILLISECONDS);
Thread.sleep(5000);
System.out.println(expiringMap.get("a")); // output "a"

@bratkartoffel
Copy link
Contributor

I think this should at least be documented on the put(K, V, long, TimeUnit) as it's kind of unexpected behaviour.
Just stumbled across this issue while trying to update an entry during an ExpirationListener.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants