-
Notifications
You must be signed in to change notification settings - Fork 1.2k
DATAREDIS-526 #205
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
DATAREDIS-526 #205
Conversation
@christophstrobl Hi,could you help me review the code? |
Can you please sign, if you haven't done already, the CLA form for |
@mp911de Yes,I have signed.my cla Number: 143520151016081625 (Duobiao Ou) |
@@ -715,11 +715,14 @@ public Long getExpire(K key, final TimeUnit timeUnit) { | |||
return execute(new RedisCallback<Long>() { | |||
|
|||
public Long doInRedis(RedisConnection connection) { |
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.
getExpire(K, TimeUnit)
has a bug if it's used with transactions/pipelining. It throws in the first place a NullPointerException
. If the call is guarded against null
access the results return the original ttl
/pTtl
value and not the converted one. I think we should move the conversion into the connections as that's the place where we're able to perform a conversion. Adding pTtl(K, TimeUnit)
and ttl(K, TimeUnit)
to RedisKeyCommands
should fix that bug.
getExpire returns now negative values without time unit conversion in case of absent values or values without a TTL set. CLA: 143520151016081625 (Duobiao Ou) Original pull request: #205.
Add author tag. Apply formatting. Add ticket references to test methods. Original pull request: #205.
…level. We now support ttl and pttl accepting a TimeUnit on connection level to return the TTL in the requested time unit. By performing the conversion inside the connection we return correct results for plain, pipelining and transaction execution. Add also JavaDoc and @OverRide to ttl/pttl methods. Original pull request: #205.
That's merged and polished with 5a3a754. We also discovered a bug when using transactions/pipelining and fixed it together with this PR. |
The redis command TTL and PTTL should return negative number(-1 or -2) when the key does not exist or the key exist but has no associated expire.
But the function getExpire like this: redisTemplate.getExpire(key1, TimeUnit.SECONDS),the return value will be 0 and redisTemplate.getExpire(key1) will be -1 or -2.