-
Notifications
You must be signed in to change notification settings - Fork 246
DEV: add TCEs to EXISTS command #2036
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
Draft
dwdougherty
wants to merge
2
commits into
main
Choose a base branch
from
DOC-5630
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
local_examples/new_tces/NRedisStack/CmdsGenericExample.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// EXAMPLE: cmds_generic | ||
// HIDE_START | ||
using NRedisStack.Tests; | ||
using StackExchange.Redis; | ||
|
||
public class CmdsGenericExample | ||
{ | ||
public void Run() | ||
{ | ||
var muxer = ConnectionMultiplexer.Connect("localhost:6379"); | ||
var db = muxer.GetDatabase(); | ||
// HIDE_END | ||
|
||
// Tests for 'copy' step. | ||
|
||
// STEP_START del | ||
bool delResult1 = db.StringSet("key1", "Hello"); | ||
Console.WriteLine(delResult1); // >>> true | ||
|
||
bool delResult2 = db.StringSet("key2", "World"); | ||
Console.WriteLine(delResult2); // >>> true | ||
|
||
long delResult3 = db.KeyDelete(["key1", "key2", "key3"]); | ||
Console.WriteLine(delResult3); // >>> 2 | ||
|
||
// Tests for 'del' step. | ||
// STEP_END | ||
|
||
// Tests for 'dump' step. | ||
|
||
// STEP_START exists | ||
bool existsResult1 = db.StringSet("key1", "Hello"); | ||
Console.WriteLine(existsResult1); // >>> true | ||
|
||
bool existsResult2 = db.KeyExists("key1"); | ||
Console.WriteLine(existsResult2); // >>> true | ||
|
||
bool existsResult3 = db.KeyExists("nosuchkey"); | ||
Console.WriteLine(existsResult3); // >>> false | ||
|
||
bool existsResult4 = db.StringSet("key2", "World"); | ||
Console.WriteLine(existsResult4); // >>> true | ||
|
||
long existsResult5 = db.KeyExists(["key1", "key2", "nosuchkey"]); | ||
Console.WriteLine(existsResult5); // >>> 2 | ||
|
||
// Tests for 'exists' step. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment shouldn't be in the example itself (probably not really necessary at all, with hindsight). Also, there are no tests - the asserts should appear in a |
||
// STEP_END | ||
|
||
// STEP_START expire | ||
bool expireResult1 = db.StringSet("mykey", "Hello"); | ||
Console.WriteLine(expireResult1); // >>> true | ||
|
||
bool expireResult2 = db.KeyExpire("mykey", new TimeSpan(0, 0, 10)); | ||
Console.WriteLine(expireResult2); // >>> true | ||
|
||
TimeSpan expireResult3 = db.KeyTimeToLive("mykey") ?? TimeSpan.Zero; | ||
Console.WriteLine(Math.Round(expireResult3.TotalSeconds)); // >>> 10 | ||
|
||
bool expireResult4 = db.StringSet("mykey", "Hello World"); | ||
Console.WriteLine(expireResult4); // >>> true | ||
|
||
TimeSpan expireResult5 = db.KeyTimeToLive("mykey") ?? TimeSpan.Zero; | ||
Console.WriteLine(Math.Round(expireResult5.TotalSeconds).ToString()); // >>> 0 | ||
|
||
bool expireResult6 = db.KeyExpire("mykey", new TimeSpan(0, 0, 10), ExpireWhen.HasExpiry); | ||
Console.WriteLine(expireResult6); // >>> false | ||
|
||
TimeSpan expireResult7 = db.KeyTimeToLive("mykey") ?? TimeSpan.Zero; | ||
Console.WriteLine(Math.Round(expireResult7.TotalSeconds)); // >>> 0 | ||
|
||
bool expireResult8 = db.KeyExpire("mykey", new TimeSpan(0, 0, 10), ExpireWhen.HasNoExpiry); | ||
Console.WriteLine(expireResult8); // >>> true | ||
|
||
TimeSpan expireResult9 = db.KeyTimeToLive("mykey") ?? TimeSpan.Zero; | ||
Console.WriteLine(Math.Round(expireResult9.TotalSeconds)); // >>> 10 | ||
|
||
// Tests for 'expire' step. | ||
// STEP_END | ||
|
||
// Tests for 'expireat' step. | ||
|
||
// Tests for 'expiretime' step. | ||
|
||
// Tests for 'keys' step. | ||
|
||
// Tests for 'migrate' step. | ||
|
||
// Tests for 'move' step. | ||
|
||
// Tests for 'object_encoding' step. | ||
|
||
// Tests for 'object_freq' step. | ||
|
||
// Tests for 'object_idletime' step. | ||
|
||
// Tests for 'object_refcount' step. | ||
|
||
// Tests for 'persist' step. | ||
|
||
// Tests for 'pexpire' step. | ||
|
||
// Tests for 'pexpireat' step. | ||
|
||
// Tests for 'pexpiretime' step. | ||
|
||
// Tests for 'pttl' step. | ||
|
||
// Tests for 'randomkey' step. | ||
|
||
// Tests for 'rename' step. | ||
|
||
// Tests for 'renamenx' step. | ||
|
||
// Tests for 'restore' step. | ||
|
||
// Tests for 'scan1' step. | ||
|
||
// Tests for 'scan2' step. | ||
|
||
// Tests for 'scan3' step. | ||
|
||
// Tests for 'scan4' step. | ||
|
||
// Tests for 'sort' step. | ||
|
||
// Tests for 'sort_ro' step. | ||
|
||
// Tests for 'touch' step. | ||
|
||
// STEP_START ttl | ||
bool ttlResult1 = db.StringSet("mykey", "Hello"); | ||
Console.WriteLine(ttlResult1); // >>> true | ||
|
||
bool ttlResult2 = db.KeyExpire("mykey", new TimeSpan(0, 0, 10)); | ||
Console.WriteLine(ttlResult2); | ||
|
||
TimeSpan ttlResult3 = db.KeyTimeToLive("mykey") ?? TimeSpan.Zero; | ||
string ttlRes = Math.Round(ttlResult3.TotalSeconds).ToString(); | ||
Console.WriteLine(Math.Round(ttlResult3.TotalSeconds)); // >>> 10 | ||
|
||
// Tests for 'ttl' step. | ||
// STEP_END | ||
|
||
// Tests for 'type' step. | ||
|
||
// Tests for 'unlink' step. | ||
|
||
// Tests for 'wait' step. | ||
|
||
// Tests for 'waitaof' step. | ||
|
||
// HIDE_START | ||
} | ||
} | ||
// HIDE_END |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There is actually quite a bit of extra crap that is needed for the testing suite but gets removed by the build script (eg, see this file that includes the test namespace and some other class derivations, etc, that enable testing).