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
70c9882f
Commit
70c9882f
authored
Mar 11, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: ServerSelectionStrategy
parent
7e06b342
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
ServerSelectionStrategy.cs
...ange.Redis/StackExchange/Redis/ServerSelectionStrategy.cs
+10
-8
No files found.
StackExchange.Redis/StackExchange/Redis/ServerSelectionStrategy.cs
View file @
70c9882f
...
...
@@ -8,7 +8,7 @@ internal sealed class ServerSelectionStrategy
{
public
const
int
NoSlot
=
-
1
,
MultipleSlots
=
-
2
;
private
const
int
RedisClusterSlotCount
=
16384
;
static
readonly
ushort
[]
crc16tab
=
private
static
readonly
ushort
[]
crc16tab
=
{
0x0000
,
0x1021
,
0x2042
,
0x3063
,
0x4084
,
0x50a5
,
0x60c6
,
0x70e7
,
0x8108
,
0x9129
,
0xa14a
,
0xb16b
,
0xc18c
,
0xd1ad
,
0xe1ce
,
0xf1ef
,
...
...
@@ -62,6 +62,7 @@ public ServerSelectionStrategy(ConnectionMultiplexer multiplexer)
/// <summary>
/// Computes the hash-slot that would be used by the given key
/// </summary>
/// <param name="key">The <see cref="RedisKey"/> to determine a slot ID for.</param>
public
unsafe
int
HashSlot
(
RedisKey
key
)
{
//HASH_SLOT = CRC16(key) mod 16384
...
...
@@ -101,7 +102,6 @@ public ServerEndPoint Select(Message message)
slot
=
message
.
GetHashSlot
(
this
);
if
(
slot
==
MultipleSlots
)
throw
ExceptionFactory
.
MultiSlot
(
multiplexer
.
IncludeDetailInExceptions
,
message
);
break
;
}
return
Select
(
slot
,
message
.
Command
,
message
.
Flags
);
}
...
...
@@ -184,6 +184,7 @@ internal int CombineSlot(int oldSlot, int newSlot)
if
(
oldSlot
==
NoSlot
)
return
newSlot
;
return
oldSlot
==
newSlot
?
oldSlot
:
MultipleSlots
;
}
internal
int
CombineSlot
(
int
oldSlot
,
RedisKey
key
)
{
if
(
oldSlot
==
MultipleSlots
||
key
.
IsNull
)
return
oldSlot
;
...
...
@@ -192,6 +193,7 @@ internal int CombineSlot(int oldSlot, RedisKey key)
if
(
oldSlot
==
NoSlot
)
return
newSlot
;
return
oldSlot
==
newSlot
?
oldSlot
:
MultipleSlots
;
}
internal
int
CountCoveredSlots
()
{
var
arr
=
map
;
...
...
@@ -211,7 +213,7 @@ internal void UpdateClusterRange(int fromInclusive, int toInclusive, ServerEndPo
}
}
static
unsafe
int
IndexOf
(
byte
*
ptr
,
byte
value
,
int
start
,
int
end
)
private
static
unsafe
int
IndexOf
(
byte
*
ptr
,
byte
value
,
int
start
,
int
end
)
{
for
(
int
offset
=
start
;
offset
<
end
;
offset
++)
if
(
ptr
[
offset
]
==
value
)
return
offset
;
...
...
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