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

TTL on objects converts seconds to milliseconds #337

Closed
nightroman opened this issue Apr 27, 2024 · 0 comments · Fixed by #338
Closed

TTL on objects converts seconds to milliseconds #337

nightroman opened this issue Apr 27, 2024 · 0 comments · Fixed by #338

Comments

@nightroman
Copy link
Contributor

nightroman commented Apr 27, 2024

Describe the bug

Getting TTL on objects (Hash, List, Set) seemingly converts seconds to milliseconds.

Steps to reproduce the bug

Use the below code snippet or the attached console app project:
GarnetIssue2.zip

using StackExchange.Redis;

using var redis = ConnectionMultiplexer.Connect("127.0.0.1:3278");
var db = redis.GetDatabase();

var key = "test:issue";

// KeyExpire on String - OK
db.KeyDelete(key);
db.StringSet(key, "a");
db.KeyExpire(key, TimeSpan.FromSeconds(10));
var ttlString = db.KeyTimeToLive(key);

// KeyExpire on Hash - NOT OK
db.KeyDelete(key);
db.HashSet(key, "a", "b");
db.KeyExpire(key, TimeSpan.FromSeconds(10));
var ttlHash = db.KeyTimeToLive(key);

// Results:
Console.WriteLine($"TTL String : {ttlString}");
Console.WriteLine($"TTL Hash   : {ttlHash}");

Output:

TTL String : 00:00:09.9980000
TTL Hash   : 00:00:00.0090000

Expected behavior

Result TTL should be approximately the same for String and Hash, about 10 seconds.

Actual results: ~10 seconds for String and ~9 milliseconds for Hash.

Tested List and Set types also show the issue.

Additional context

  • Garnet 1.0.6
  • StackExchange.Redis 2.7.33
  • Windows 11
@nightroman nightroman changed the title Setting expire on objects converts seconds to milliseconds TTL on objects converts seconds to milliseconds Apr 27, 2024
TedHartMS pushed a commit that referenced this issue Apr 29, 2024
Use `GarnetObjectType.PTtl` or `GarnetObjectType.Ttl` depending on the flag `milliseconds`.
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 a pull request may close this issue.

1 participant