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
76ed030a
Commit
76ed030a
authored
Aug 26, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SWAPDB: Add tests + fix
This wasn't actually working due to needing a "needs DB" exemption, fixed up!
parent
30bbb4b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
Message.cs
src/StackExchange.Redis/Message.cs
+1
-0
Databases.cs
tests/StackExchange.Redis.Tests/Databases.cs
+34
-0
No files found.
src/StackExchange.Redis/Message.cs
View file @
76ed030a
...
...
@@ -562,6 +562,7 @@ internal static bool RequiresDatabase(RedisCommand command)
case
RedisCommand
.
SLAVEOF
:
case
RedisCommand
.
SLOWLOG
:
case
RedisCommand
.
SUBSCRIBE
:
case
RedisCommand
.
SWAPDB
:
case
RedisCommand
.
SYNC
:
case
RedisCommand
.
TIME
:
case
RedisCommand
.
UNSUBSCRIBE
:
...
...
tests/StackExchange.Redis.Tests/Databases.cs
View file @
76ed030a
...
...
@@ -82,5 +82,39 @@ public async Task MultiDatabases()
Assert
.
Equal
(
"c"
,
await
c
);
// db:2
}
}
[
Fact
]
public
async
Task
SwapDatabases
()
{
using
(
var
muxer
=
Create
(
allowAdmin
:
true
))
{
RedisKey
key
=
Me
();
var
db0id
=
TestConfig
.
GetDedicatedDB
(
muxer
);
var
db0
=
muxer
.
GetDatabase
(
db0id
);
var
db1id
=
TestConfig
.
GetDedicatedDB
(
muxer
);
var
db1
=
muxer
.
GetDatabase
(
db1id
);
db0
.
KeyDelete
(
key
,
CommandFlags
.
FireAndForget
);
db1
.
KeyDelete
(
key
,
CommandFlags
.
FireAndForget
);
db0
.
StringSet
(
key
,
"a"
,
flags
:
CommandFlags
.
FireAndForget
);
db1
.
StringSet
(
key
,
"b"
,
flags
:
CommandFlags
.
FireAndForget
);
var
a
=
db0
.
StringGetAsync
(
key
);
var
b
=
db1
.
StringGetAsync
(
key
);
Assert
.
Equal
(
"a"
,
await
a
);
// db:0
Assert
.
Equal
(
"b"
,
await
b
);
// db:1
var
server
=
GetServer
(
muxer
);
server
.
SwapDatabases
(
db0id
,
db1id
);
var
aNew
=
db1
.
StringGetAsync
(
key
);
var
bNew
=
db0
.
StringGetAsync
(
key
);
Assert
.
Equal
(
"a"
,
await
aNew
);
// db:1
Assert
.
Equal
(
"b"
,
await
bNew
);
// db:0
}
}
}
}
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