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
64289d42
Commit
64289d42
authored
Jul 06, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
booleans are hard
parent
dccca67c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
18 deletions
+19
-18
Massive Delete.cs
...kExchange.Redis.Tests/Booksleeve/Issues/Massive Delete.cs
+8
-7
PubSub.cs
StackExchange.Redis.Tests/Booksleeve/PubSub.cs
+1
-1
PubSub.cs
StackExchange.Redis.Tests/PubSub.cs
+9
-9
RedisSubscriber.cs
StackExchange.Redis/StackExchange/Redis/RedisSubscriber.cs
+1
-1
No files found.
StackExchange.Redis.Tests/Booksleeve/Issues/Massive Delete.cs
View file @
64289d42
using
System.Diagnostics
;
using
System
;
using
System.Diagnostics
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Xunit
;
...
...
@@ -29,20 +30,20 @@ public Massive_Delete(ITestOutputHelper output) : base(output)
private
const
string
todoKey
=
"todo"
;
[
Fact
]
public
void
ExecuteMassiveDelete
()
public
async
Task
ExecuteMassiveDelete
()
{
var
watch
=
Stopwatch
.
StartNew
();
using
(
var
muxer
=
GetUnsecuredConnection
())
using
(
var
throttle
=
new
SemaphoreSlim
(
1
))
{
var
conn
=
muxer
.
GetDatabase
(
db
);
var
originally
Task
=
conn
.
SetLengthAsync
(
todoKey
);
var
originally
=
await
conn
.
SetLengthAsync
(
todoKey
);
int
keepChecking
=
1
;
Task
last
=
null
;
while
(
Volatile
.
Read
(
ref
keepChecking
)
==
1
)
{
throttle
.
Wait
();
// acquire
conn
.
SetPopAsync
(
todoKey
).
ContinueWith
(
task
=>
var
x
=
conn
.
SetPopAsync
(
todoKey
).
ContinueWith
(
task
=>
{
throttle
.
Release
();
if
(
task
.
IsCompleted
)
...
...
@@ -57,14 +58,14 @@ public void ExecuteMassiveDelete()
}
}
});
GC
.
KeepAlive
(
x
);
}
if
(
last
!=
null
)
{
conn
.
Wait
(
last
)
;
await
last
;
}
watch
.
Stop
();
long
originally
=
conn
.
Wait
(
originallyTask
),
remaining
=
conn
.
SetLength
(
todoKey
);
long
remaining
=
await
conn
.
SetLengthAsync
(
todoKey
);
Output
.
WriteLine
(
"From {0} to {1}; {2}ms"
,
originally
,
remaining
,
watch
.
ElapsedMilliseconds
);
...
...
StackExchange.Redis.Tests/Booksleeve/PubSub.cs
View file @
64289d42
...
...
@@ -46,7 +46,7 @@ public void TestMassivePublishWithWithoutFlush_Remote()
private
void
TestMassivePublish
(
ISubscriber
conn
,
string
channel
,
string
caption
)
{
const
int
loop
=
10000
0
;
const
int
loop
=
10000
;
GC
.
Collect
(
GC
.
MaxGeneration
,
GCCollectionMode
.
Forced
);
GC
.
WaitForPendingFinalizers
();
...
...
StackExchange.Redis.Tests/PubSub.cs
View file @
64289d42
...
...
@@ -42,13 +42,13 @@ public void ExplicitPublishMode()
}
[
Theory
]
[
InlineData
(
null
,
false
)]
[
InlineData
(
""
,
false
)]
[
InlineData
(
"Foo:"
,
false
)]
[
InlineData
(
null
,
true
)]
[
InlineData
(
""
,
true
)]
[
InlineData
(
"Foo:"
,
true
)]
public
void
TestBasicPubSub
(
string
channelPrefix
,
bool
wildCard
)
[
InlineData
(
null
,
false
,
"a"
)]
[
InlineData
(
""
,
false
,
"b"
)]
[
InlineData
(
"Foo:"
,
false
,
"c"
)]
[
InlineData
(
null
,
true
,
"d"
)]
[
InlineData
(
""
,
true
,
"e"
)]
[
InlineData
(
"Foo:"
,
true
,
"f"
)]
public
void
TestBasicPubSub
(
string
channelPrefix
,
bool
wildCard
,
string
breaker
)
{
using
(
var
muxer
=
Create
(
channelPrefix
:
channelPrefix
))
{
...
...
@@ -57,8 +57,8 @@ public void TestBasicPubSub(string channelPrefix, bool wildCard)
Ping
(
muxer
,
pub
,
sub
);
HashSet
<
string
>
received
=
new
HashSet
<
string
>();
int
secondHandler
=
0
;
string
subChannel
=
wildCard
?
"a*c"
:
"abc"
;
const
string
pubChannel
=
"abc"
;
string
subChannel
=
(
wildCard
?
"a*c"
:
"abc"
)
+
breaker
;
string
pubChannel
=
"abc"
+
breaker
;
Action
<
RedisChannel
,
RedisValue
>
handler1
=
(
channel
,
payload
)
=>
{
lock
(
received
)
...
...
StackExchange.Redis/StackExchange/Redis/RedisSubscriber.cs
View file @
64289d42
...
...
@@ -102,7 +102,7 @@ internal Task RemoveSubscription(RedisChannel channel, Action<RedisChannel, Redi
{
lock
(
subscriptions
)
{
bool
asAsync
=
ChannelMessageQueue
.
IsOneOf
(
handler
);
bool
asAsync
=
!
ChannelMessageQueue
.
IsOneOf
(
handler
);
if
(
subscriptions
.
TryGetValue
(
channel
,
out
Subscription
sub
)
&&
sub
.
Remove
(
asAsync
,
handler
))
{
subscriptions
.
Remove
(
channel
);
...
...
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