Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
7dfaee46
Commit
7dfaee46
authored
Aug 26, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests: add KeyExists (including varadic)
parent
f7e1bb15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
Keys.cs
tests/StackExchange.Redis.Tests/Keys.cs
+67
-0
No files found.
tests/StackExchange.Redis.Tests/Keys.cs
View file @
7dfaee46
...
...
@@ -108,6 +108,73 @@ public void PrependAppend()
}
}
[
Fact
]
public
void
Exists
()
{
using
(
var
muxer
=
Create
())
{
RedisKey
key
=
Me
();
RedisKey
key2
=
Me
()
+
"2"
;
var
db
=
muxer
.
GetDatabase
();
db
.
KeyDelete
(
key
,
CommandFlags
.
FireAndForget
);
db
.
KeyDelete
(
key2
,
CommandFlags
.
FireAndForget
);
Assert
.
False
(
db
.
KeyExists
(
key
));
Assert
.
False
(
db
.
KeyExists
(
key2
));
Assert
.
Equal
(
0
,
db
.
KeyExists
(
new
[]
{
key
,
key2
}));
db
.
StringSet
(
key
,
"new value"
,
flags
:
CommandFlags
.
FireAndForget
);
Assert
.
True
(
db
.
KeyExists
(
key
));
Assert
.
False
(
db
.
KeyExists
(
key2
));
Assert
.
Equal
(
1
,
db
.
KeyExists
(
new
[]
{
key
,
key2
}));
db
.
StringSet
(
key2
,
"new value"
,
flags
:
CommandFlags
.
FireAndForget
);
Assert
.
True
(
db
.
KeyExists
(
key
));
Assert
.
True
(
db
.
KeyExists
(
key2
));
Assert
.
Equal
(
2
,
db
.
KeyExists
(
new
[]
{
key
,
key2
}));
}
}
[
Fact
]
public
async
Task
ExistsAsync
()
{
using
(
var
muxer
=
Create
())
{
RedisKey
key
=
Me
();
RedisKey
key2
=
Me
()
+
"2"
;
var
db
=
muxer
.
GetDatabase
();
db
.
KeyDelete
(
key
,
CommandFlags
.
FireAndForget
);
db
.
KeyDelete
(
key2
,
CommandFlags
.
FireAndForget
);
var
a1
=
db
.
KeyExistsAsync
(
key
).
ForAwait
();
var
a2
=
db
.
KeyExistsAsync
(
key2
).
ForAwait
();
var
a3
=
db
.
KeyExistsAsync
(
new
[]
{
key
,
key2
}).
ForAwait
();
db
.
StringSet
(
key
,
"new value"
,
flags
:
CommandFlags
.
FireAndForget
);
var
b1
=
db
.
KeyExistsAsync
(
key
).
ForAwait
();
var
b2
=
db
.
KeyExistsAsync
(
key2
).
ForAwait
();
var
b3
=
db
.
KeyExistsAsync
(
new
[]
{
key
,
key2
}).
ForAwait
();
db
.
StringSet
(
key2
,
"new value"
,
flags
:
CommandFlags
.
FireAndForget
);
var
c1
=
db
.
KeyExistsAsync
(
key
).
ForAwait
();
var
c2
=
db
.
KeyExistsAsync
(
key2
).
ForAwait
();
var
c3
=
db
.
KeyExistsAsync
(
new
[]
{
key
,
key2
}).
ForAwait
();
Assert
.
False
(
await
a1
);
Assert
.
False
(
await
a2
);
Assert
.
Equal
(
0
,
await
a3
);
Assert
.
True
(
await
b1
);
Assert
.
False
(
await
b2
);
Assert
.
Equal
(
1
,
await
b3
);
Assert
.
True
(
await
c1
);
Assert
.
True
(
await
c2
);
Assert
.
Equal
(
2
,
await
c3
);
}
}
[
Fact
]
public
async
Task
IdleTime
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment