-
Notifications
You must be signed in to change notification settings - Fork 274
DEV: add TCEs to HEXPIRE command page #2253
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
Changes from 1 commit
04f111f
b16f021
3390efb
c54769a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // EXAMPLE: cmds_hash | ||
| using StackExchange.Redis; | ||
| using Xunit; | ||
| using System.Linq; | ||
|
|
||
| namespace Doc; | ||
|
|
||
|
|
@@ -110,5 +111,40 @@ public void Run() | |
| // >>> Hello, World | ||
| // STEP_END | ||
| Assert.Equal("Hello, World", string.Join(", ", hValsResult)); | ||
| db.KeyDelete("myhash"); | ||
|
|
||
| // STEP_START hexpire | ||
| // Set up hash with fields | ||
| db.HashSet("myhash", | ||
| [ | ||
| new("field1", "Hello"), | ||
| new("field2", "World") | ||
| ] | ||
| ); | ||
|
|
||
| // Set expiration on hash fields using raw Execute | ||
| RedisResult hexpireRes1 = db.Execute("HEXPIRE", "myhash", 10, "FIELDS", 2, "field1", "field2"); | ||
|
||
| Console.WriteLine(string.Join(", ", (RedisValue[])hexpireRes1)); | ||
| // >>> 1, 1 | ||
|
|
||
| // Check TTL of the fields using raw Execute | ||
| RedisResult hexpireRes2 = db.Execute("HTTL", "myhash", "FIELDS", 2, "field1", "field2"); | ||
| RedisValue[] ttlValues = (RedisValue[])hexpireRes2; | ||
| Console.WriteLine(ttlValues.Length); | ||
| // >>> 2 | ||
|
|
||
| // Try to set expiration on non-existent field | ||
| RedisResult hexpireRes3 = db.Execute("HEXPIRE", "myhash", 10, "FIELDS", 1, "nonexistent"); | ||
| Console.WriteLine(string.Join(", ", (RedisValue[])hexpireRes3)); | ||
| // >>> -2 | ||
| // STEP_END | ||
|
|
||
| RedisValue[] expireResult1 = (RedisValue[])hexpireRes1; | ||
| RedisValue[] expireResult3 = (RedisValue[])hexpireRes3; | ||
| Assert.Equal("1, 1", string.Join(", ", expireResult1)); | ||
| Assert.Equal(2, ttlValues.Length); | ||
| Assert.True(ttlValues.All(ttl => (int)ttl > 0)); // TTL should be positive | ||
| Assert.Equal("-2", string.Join(", ", expireResult3)); | ||
| db.KeyDelete("myhash"); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.