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

add ValueOperation setIFAbsent with expiry for key #2730

Closed
XKXK1 opened this issue Oct 11, 2023 · 4 comments
Closed

add ValueOperation setIFAbsent with expiry for key #2730

XKXK1 opened this issue Oct 11, 2023 · 4 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@XKXK1
Copy link

XKXK1 commented Oct 11, 2023

I already ran into the problem of not being able to set an expiry time for a key when using the setIfAbsent method for the ValueOperation multiple times now.

What do you think about adding the possibility to set the expiry time when using setIfAbsent ValueOperation?

It is possible to execute this directly by doing the following, but not directly using the ValueOperation:

redisTemplate.execute((RedisCallback<Object>) connection -> {
            StringRedisConnection stringRedisConn = (StringRedisConnection) connection;
            return stringRedisConn.set(
                "key",
                "locked",
                Expiration.from(Duration.ofSeconds(10)),
                RedisStringCommands.SetOption.SET_IF_ABSENT);
        });
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 11, 2023
@mp911de
Copy link
Member

mp911de commented Oct 11, 2023

I'm not sure I follow. Are you referring to ValueOperations.setIfAbsent(K key, V value, Duration timeout)?

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Oct 11, 2023
@XKXK1
Copy link
Author

XKXK1 commented Oct 11, 2023

I'm not sure I follow. Are you referring to ValueOperations.setIfAbsent(K key, V value, Duration timeout)?

exactly, and I am not talking about the timeout but about an expiry for the key itself

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 11, 2023
@mp911de
Copy link
Member

mp911de commented Oct 11, 2023

setIfAbsent calls connection.set(rawKey, rawValue, expiration, SetOption.ifAbsent()) (SET <key> <value> EX … NX)

I am not talking about the timeout but about an expiry for the key itself

The Duration timeout parameter translates to the TTL. So I still don't understand what you're asking for.

@mp911de mp911de added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Oct 11, 2023
@XKXK1
Copy link
Author

XKXK1 commented Oct 11, 2023

Sorry this was a mistake on my side. You are absolutely right. At some point I probably was checking the wrong documentation. Thanks for checking

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 11, 2023
@jxblum jxblum added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Oct 12, 2023
@jxblum jxblum closed this as completed Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants