Skip to content

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

Closed
wants to merge 1 commit into from
Closed

DATAREDIS-526 #205

wants to merge 1 commit into from

Conversation

oudb
Copy link
Contributor

@oudb oudb commented Jun 23, 2016

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.

@oudb
Copy link
Contributor Author

oudb commented Jun 23, 2016

@christophstrobl Hi,could you help me review the code?

@mp911de
Copy link
Member

mp911de commented Jun 24, 2016

Can you please sign, if you haven't done already, the CLA form for Spring Data Access with project lead Oliver Gierke?

@oudb
Copy link
Contributor Author

oudb commented Jun 25, 2016

@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) {
Copy link
Member

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.

mp911de pushed a commit that referenced this pull request Jul 8, 2016
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.
mp911de added a commit that referenced this pull request Jul 8, 2016
Add author tag. Apply formatting. Add ticket references to test methods.
Original pull request: #205.
mp911de added a commit that referenced this pull request Jul 8, 2016
…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.
@mp911de
Copy link
Member

mp911de commented Jul 8, 2016

That's merged and polished with 5a3a754. We also discovered a bug when using transactions/pipelining and fixed it together with this PR.

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

Successfully merging this pull request may close these issues.

2 participants