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
2e5923b0
Commit
2e5923b0
authored
Mar 21, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Misc cleanup (including line endings for some)
parent
d5fff16f
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
4988 additions
and
4987 deletions
+4988
-4987
TestBase.cs
StackExchange.Redis.Tests/TestBase.cs
+1
-1
ClusterConfiguration.cs
...xchange.Redis/StackExchange/Redis/ClusterConfiguration.cs
+11
-13
Condition.cs
StackExchange.Redis/StackExchange/Redis/Condition.cs
+114
-110
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+2
-2
ExceptionFactory.cs
StackExchange.Redis/StackExchange/Redis/ExceptionFactory.cs
+115
-115
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+1178
-1178
RedisDatabase.cs
StackExchange.Redis/StackExchange/Redis/RedisDatabase.cs
+2726
-2726
ResultProcessor.cs
StackExchange.Redis/StackExchange/Redis/ResultProcessor.cs
+355
-355
ServerEndPoint.cs
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
+2
-3
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+484
-484
No files found.
StackExchange.Redis.Tests/TestBase.cs
View file @
2e5923b0
...
...
@@ -103,7 +103,7 @@ protected void OnInternalError(object sender, InternalErrorEventArgs e)
}
private
int
privateFailCount
;
private
static
AsyncLocal
<
int
>
sharedFailCount
=
new
AsyncLocal
<
int
>();
private
static
readonly
AsyncLocal
<
int
>
sharedFailCount
=
new
AsyncLocal
<
int
>();
private
volatile
int
expectedFailCount
;
private
readonly
List
<
string
>
privateExceptions
=
new
List
<
string
>();
...
...
StackExchange.Redis/StackExchange/Redis/ClusterConfiguration.cs
View file @
2e5923b0
...
...
@@ -97,8 +97,8 @@ public static bool TryParse(string range, out SlotRange value)
/// <param name="other">The other slot range to compare to.</param>
public
int
CompareTo
(
SlotRange
other
)
{
int
delta
=
(
int
)
this
.
from
-
(
int
)
other
.
from
;
return
delta
==
0
?
(
int
)
t
his
.
t
o
-
(
int
)
other
.
to
:
delta
;
int
delta
=
(
int
)
from
-
(
int
)
other
.
from
;
return
delta
==
0
?
(
int
)
to
-
(
int
)
other
.
to
:
delta
;
}
/// <summary>
...
...
@@ -161,7 +161,7 @@ internal ClusterConfiguration(ServerSelectionStrategy serverSelectionStrategy, s
{
// Beware: Any exception thrown here will wreak silent havoc like inability to connect to cluster nodes or non returning calls
this
.
serverSelectionStrategy
=
serverSelectionStrategy
;
this
.
Origin
=
origin
;
Origin
=
origin
;
using
(
var
reader
=
new
StringReader
(
nodes
))
{
string
line
;
...
...
@@ -178,7 +178,7 @@ internal ClusterConfiguration(ServerSelectionStrategy serverSelectionStrategy, s
// make sure that things like clusterConfiguration[clusterConfiguration.Origin]
// will work as expected.
if
(
node
.
IsMyself
)
this
.
Origin
=
node
.
EndPoint
;
Origin
=
node
.
EndPoint
;
if
(
nodeLookup
.
ContainsKey
(
node
.
EndPoint
))
{
...
...
@@ -286,7 +286,7 @@ internal ClusterNode(ClusterConfiguration configuration, string raw, EndPoint or
{
// https://redis.io/commands/cluster-nodes
this
.
configuration
=
configuration
;
this
.
Raw
=
raw
;
Raw
=
raw
;
var
parts
=
raw
.
Split
(
StringSplits
.
Space
);
var
flags
=
parts
[
2
].
Split
(
StringSplits
.
Comma
);
...
...
@@ -319,8 +319,7 @@ internal ClusterNode(ClusterConfiguration configuration, string raw, EndPoint or
{
if
(
SlotRange
.
TryParse
(
parts
[
i
],
out
SlotRange
range
))
{
if
(
slots
==
null
)
slots
=
new
List
<
SlotRange
>(
parts
.
Length
-
i
);
slots
.
Add
(
range
);
(
slots
??
(
slots
=
new
List
<
SlotRange
>(
parts
.
Length
-
i
))).
Add
(
range
);
}
}
Slots
=
slots
?.
AsReadOnly
()
??
NoSlots
;
...
...
@@ -338,10 +337,9 @@ public IList<ClusterNode> Children
List
<
ClusterNode
>
nodes
=
null
;
foreach
(
var
node
in
configuration
.
Nodes
)
{
if
(
node
.
ParentNodeId
==
this
.
NodeId
)
if
(
node
.
ParentNodeId
==
NodeId
)
{
if
(
nodes
==
null
)
nodes
=
new
List
<
ClusterNode
>();
nodes
.
Add
(
node
);
(
nodes
??
(
nodes
=
new
List
<
ClusterNode
>())).
Add
(
node
);
}
}
children
=
nodes
?.
AsReadOnly
()
??
NoNodes
;
...
...
@@ -416,14 +414,14 @@ public int CompareTo(ClusterNode other)
{
if
(
other
==
null
)
return
-
1
;
if
(
this
.
IsSlave
!=
other
.
IsSlave
)
return
IsSlave
?
1
:
-
1
;
// masters first
if
(
IsSlave
!=
other
.
IsSlave
)
return
IsSlave
?
1
:
-
1
;
// masters first
if
(
IsSlave
)
// both slaves? compare by parent, so we get masters A, B, C and then slaves of A, B, C
{
int
i
=
string
.
CompareOrdinal
(
this
.
ParentNodeId
,
other
.
ParentNodeId
);
int
i
=
string
.
CompareOrdinal
(
ParentNodeId
,
other
.
ParentNodeId
);
if
(
i
!=
0
)
return
i
;
}
return
string
.
CompareOrdinal
(
this
.
NodeId
,
other
.
NodeId
);
return
string
.
CompareOrdinal
(
NodeId
,
other
.
NodeId
);
}
/// <summary>
...
...
StackExchange.Redis/StackExchange/Redis/Condition.cs
View file @
2e5923b0
...
...
@@ -8,7 +8,7 @@ namespace StackExchange.Redis
/// </summary>
public
abstract
class
Condition
{
internal
abstract
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
);
internal
abstract
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
);
private
Condition
()
{
}
...
...
@@ -293,7 +293,7 @@ private class ConditionMessage : Message.CommandKeyBase
public
ConditionMessage
(
Condition
condition
,
int
db
,
CommandFlags
flags
,
RedisCommand
command
,
RedisKey
key
,
RedisValue
value
)
:
base
(
db
,
flags
,
command
,
key
)
{
this
.
Condition
=
condition
;
Condition
=
condition
;
this
.
value
=
value
;
// note no assert here
}
...
...
@@ -322,7 +322,7 @@ internal class ExistsCondition : Condition
private
readonly
RedisType
type
;
private
readonly
RedisCommand
cmd
;
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
{
return
new
ExistsCondition
(
map
(
key
),
type
,
expectedValue
,
expectedResult
);
}
...
...
@@ -335,11 +335,14 @@ public ExistsCondition(RedisKey key, RedisType type, RedisValue expectedValue, b
this
.
expectedValue
=
expectedValue
;
this
.
expectedResult
=
expectedResult
;
if
(
expectedValue
.
IsNull
)
{
if
(
expectedValue
.
IsNull
)
{
cmd
=
RedisCommand
.
EXISTS
;
}
else
{
switch
(
type
)
{
else
{
switch
(
type
)
{
case
RedisType
.
Hash
:
cmd
=
RedisCommand
.
HEXISTS
;
break
;
...
...
@@ -403,7 +406,7 @@ internal override bool TryValidate(RawResult result, out bool value)
internal
class
EqualsCondition
:
Condition
{
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
{
return
new
EqualsCondition
(
map
(
key
),
hashField
,
expectedEqual
,
expectedValue
);
}
...
...
@@ -467,7 +470,7 @@ internal override bool TryValidate(RawResult result, out bool value)
internal
class
ListCondition
:
Condition
{
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
{
return
new
ListCondition
(
map
(
key
),
index
,
expectedResult
,
expectedValue
);
}
...
...
@@ -535,7 +538,7 @@ internal override bool TryValidate(RawResult result, out bool value)
internal
class
LengthCondition
:
Condition
{
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
internal
override
Condition
MapKeys
(
Func
<
RedisKey
,
RedisKey
>
map
)
{
return
new
LengthCondition
(
map
(
key
),
type
,
compareToResult
,
expectedLength
);
}
...
...
@@ -553,7 +556,8 @@ public LengthCondition(RedisKey key, RedisType type, int compareToResult, long e
this
.
compareToResult
=
compareToResult
;
this
.
expectedLength
=
expectedLength
;
this
.
type
=
type
;
switch
(
type
)
{
switch
(
type
)
{
case
RedisType
.
Hash
:
cmd
=
RedisCommand
.
HLEN
;
break
;
...
...
@@ -616,7 +620,7 @@ internal override bool TryValidate(RawResult result, out bool value)
case
ResultType
.
SimpleString
:
case
ResultType
.
Integer
:
var
parsed
=
result
.
AsRedisValue
();
value
=
parsed
.
IsInteger
&&
(
expectedLength
.
CompareTo
((
long
)
parsed
)
==
compareToResult
);
value
=
parsed
.
IsInteger
&&
(
expectedLength
.
CompareTo
((
long
)
parsed
)
==
compareToResult
);
ConnectionMultiplexer
.
TraceWithoutContext
(
"actual: "
+
(
string
)
parsed
+
"; expected: "
+
expectedLength
+
"; wanted: "
+
GetComparisonString
()
+
"; voting: "
+
value
);
return
true
;
...
...
@@ -640,7 +644,7 @@ public sealed class ConditionResult
internal
ConditionResult
(
Condition
condition
)
{
this
.
Condition
=
condition
;
Condition
=
condition
;
resultBox
=
ResultBox
<
bool
>.
Get
(
condition
);
}
...
...
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
2e5923b0
...
...
@@ -98,7 +98,7 @@ internal static string TryGetAzureRoleInstanceIdNoThrow()
var
currentRoleInstanceId
=
currentRoleInstanceProp
.
GetValue
(
null
,
null
);
roleInstanceId
=
currentRoleInstanceId
.
GetType
().
GetProperty
(
"Id"
).
GetValue
(
currentRoleInstanceId
,
null
).
ToString
();
if
(
S
tring
.
IsNullOrEmpty
(
roleInstanceId
))
if
(
s
tring
.
IsNullOrEmpty
(
roleInstanceId
))
{
roleInstanceId
=
null
;
}
...
...
@@ -2050,7 +2050,7 @@ void add(string lk, string sk, string v)
add
(
"Client-Name"
,
"clientName"
,
ClientName
);
add
(
"Server-Endpoint"
,
"serverEndpoint"
,
server
.
EndPoint
.
ToString
());
var
hashSlot
=
message
.
GetHashSlot
(
this
.
ServerSelectionStrategy
);
var
hashSlot
=
message
.
GetHashSlot
(
ServerSelectionStrategy
);
// only add keyslot if its a valid cluster key slot
if
(
hashSlot
!=
ServerSelectionStrategy
.
NoSlot
)
{
...
...
StackExchange.Redis/StackExchange/Redis/ExceptionFactory.cs
View file @
2e5923b0
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
2e5923b0
...
...
@@ -943,7 +943,7 @@ private void MatchResult(RawResult result)
msg
=
outstanding
.
Dequeue
();
}
Multiplexer
.
Trace
(
"Response to: "
+
msg
.
ToString
(),
physicalName
);
Multiplexer
.
Trace
(
"Response to: "
+
msg
,
physicalName
);
if
(
msg
.
ComputeResult
(
this
,
result
))
{
Bridge
.
CompleteSyncOrAsync
(
msg
);
...
...
StackExchange.Redis/StackExchange/Redis/RedisDatabase.cs
View file @
2e5923b0
StackExchange.Redis/StackExchange/Redis/ResultProcessor.cs
View file @
2e5923b0
...
...
@@ -309,7 +309,7 @@ internal sealed class TimerMessage : Message
public
TimerMessage
(
int
db
,
CommandFlags
flags
,
RedisCommand
command
,
RedisValue
value
)
:
base
(
db
,
flags
,
command
)
{
this
.
Watch
=
Stopwatch
.
StartNew
();
Watch
=
Stopwatch
.
StartNew
();
this
.
value
=
value
;
}
...
...
@@ -1313,7 +1313,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
return
true
;
case
ResultType
.
MultiBulk
:
var
arr
=
result
.
GetItems
();
if
(
arr
.
Length
==
1
)
if
(
arr
.
Length
==
1
)
{
SetResult
(
message
,
arr
[
0
].
GetString
());
return
true
;
...
...
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
View file @
2e5923b0
...
...
@@ -199,7 +199,7 @@ public void SetClusterConfiguration(ClusterConfiguration configuration)
multiplexer
.
Trace
(
"Updating cluster ranges..."
);
multiplexer
.
UpdateClusterRange
(
configuration
);
multiplexer
.
Trace
(
"Resolving genealogy..."
);
var
thisNode
=
configuration
.
Nodes
.
FirstOrDefault
(
x
=>
x
.
EndPoint
.
Equals
(
this
.
EndPoint
));
var
thisNode
=
configuration
.
Nodes
.
FirstOrDefault
(
x
=>
x
.
EndPoint
.
Equals
(
EndPoint
));
if
(
thisNode
!=
null
)
{
List
<
ServerEndPoint
>
slaves
=
null
;
...
...
@@ -212,8 +212,7 @@ public void SetClusterConfiguration(ClusterConfiguration configuration)
}
else
if
(
node
.
ParentNodeId
==
thisNode
.
NodeId
)
{
if
(
slaves
==
null
)
slaves
=
new
List
<
ServerEndPoint
>();
slaves
.
Add
(
multiplexer
.
GetServerEndPoint
(
node
.
EndPoint
));
(
slaves
??
(
slaves
=
new
List
<
ServerEndPoint
>())).
Add
(
multiplexer
.
GetServerEndPoint
(
node
.
EndPoint
));
}
}
Master
=
master
;
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
2e5923b0
...
...
@@ -185,8 +185,8 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback, C
socket
.
NoDelay
=
true
;
try
{
CompletionType
connectCompletionType
=
CompletionType
.
Any
;
this
.
ShouldForceConnectCompletionType
(
ref
connectCompletionType
);
var
connectCompletionType
=
CompletionType
.
Any
;
ShouldForceConnectCompletionType
(
ref
connectCompletionType
);
var
formattedEndpoint
=
Format
.
ToString
(
endpoint
);
var
tuple
=
Tuple
.
Create
(
socket
,
callback
);
...
...
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