-
Couldn't load subscription status.
- Fork 3
Redis config improvements #5
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! Since I've got little experience with Redis I'd like to ask some clarifying questions though.
| val mono = when (command) { | ||
| RedisCommand.HashSet -> info.commands.hset(info.entryName, key, value) | ||
| RedisCommand.Set -> info.commands.set(key, value) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression that hashing was always advised over non-hashing. What would be some situations where not using a hash is beneficial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik you can't set a TTL for individual hash values but you can with a set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reading up on it seems like trying to expire a hset would result in the entire has being expired, so you're right there.
If that's the only practical difference though, we shouldn't allow choosing both a command and a TTL, the two decisions depend on eachother.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe something like this?
sealed class RedisCommand {
object HashSet : RedisCommand()
data class Set(val ttl: Long? = null) : RedisCommand()
}| fun <T> Mono<T>.cache(ttl: Duration?): Mono<T> { | ||
| return if (ttl != null) cache(ttl.toJavaDuration()) else this | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this just cache the mono? I was under the impression you need to call something like RedisKeyReactiveCommands#expire to inform redis of a key's TTL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I'm not very familiar with lettuce or rxjava to begin with, I'll switch it over.
hsetorset