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
7f807f13
Commit
7f807f13
authored
Aug 13, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RedisSubscriber should prefer PING to UNSUBSCRIBE in Ping[Async]()
parent
8a3f264a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
RedisSubscriber.cs
StackExchange.Redis/RedisSubscriber.cs
+22
-8
No files found.
StackExchange.Redis/RedisSubscriber.cs
View file @
7f807f13
...
@@ -320,18 +320,32 @@ public bool IsConnected(RedisChannel channel = default(RedisChannel))
...
@@ -320,18 +320,32 @@ public bool IsConnected(RedisChannel channel = default(RedisChannel))
public
override
TimeSpan
Ping
(
CommandFlags
flags
=
CommandFlags
.
None
)
public
override
TimeSpan
Ping
(
CommandFlags
flags
=
CommandFlags
.
None
)
{
{
// can't use regular PING, but we can unsubscribe from something random that we weren't even subscribed to...
var
msg
=
CreatePingMessage
(
flags
,
out
var
server
);
RedisValue
channel
=
Guid
.
NewGuid
().
ToByteArray
();
return
ExecuteSync
(
msg
,
ResultProcessor
.
ResponseTimer
,
server
);
var
msg
=
ResultProcessor
.
TimingProcessor
.
CreateMessage
(-
1
,
flags
,
RedisCommand
.
UNSUBSCRIBE
,
channel
);
return
ExecuteSync
(
msg
,
ResultProcessor
.
ResponseTimer
);
}
}
public
override
Task
<
TimeSpan
>
PingAsync
(
CommandFlags
flags
=
CommandFlags
.
None
)
public
override
Task
<
TimeSpan
>
PingAsync
(
CommandFlags
flags
=
CommandFlags
.
None
)
{
{
// can't use regular PING, but we can unsubscribe from something random that we weren't even subscribed to...
var
msg
=
CreatePingMessage
(
flags
,
out
var
server
);
RedisValue
channel
=
Guid
.
NewGuid
().
ToByteArray
();
return
ExecuteAsync
(
msg
,
ResultProcessor
.
ResponseTimer
,
server
);
var
msg
=
ResultProcessor
.
TimingProcessor
.
CreateMessage
(-
1
,
flags
,
RedisCommand
.
UNSUBSCRIBE
,
channel
);
}
return
ExecuteAsync
(
msg
,
ResultProcessor
.
ResponseTimer
);
private
Message
CreatePingMessage
(
CommandFlags
flags
,
out
ServerEndPoint
server
)
{
bool
usePing
;
try
{
usePing
=
GetFeatures
(-
1
,
default
,
flags
,
out
server
).
PingOnSubscriber
;
}
catch
{
usePing
=
false
;
server
=
null
;
}
if
(
usePing
)
{
return
ResultProcessor
.
TimingProcessor
.
CreateMessage
(-
1
,
flags
,
RedisCommand
.
PING
);
}
else
{
// can't use regular PING, but we can unsubscribe from something random that we weren't even subscribed to...
RedisValue
channel
=
Guid
.
NewGuid
().
ToByteArray
();
return
ResultProcessor
.
TimingProcessor
.
CreateMessage
(-
1
,
flags
,
RedisCommand
.
UNSUBSCRIBE
,
channel
);
}
}
}
public
long
Publish
(
RedisChannel
channel
,
RedisValue
message
,
CommandFlags
flags
=
CommandFlags
.
None
)
public
long
Publish
(
RedisChannel
channel
,
RedisValue
message
,
CommandFlags
flags
=
CommandFlags
.
None
)
...
...
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