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
3fd054da
Commit
3fd054da
authored
Jul 05, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
9584d15b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
21 deletions
+21
-21
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+17
-17
RedisDatabase.cs
StackExchange.Redis/StackExchange/Redis/RedisDatabase.cs
+1
-1
RedisValue.cs
StackExchange.Redis/StackExchange/Redis/RedisValue.cs
+1
-1
ResultProcessor.cs
StackExchange.Redis/StackExchange/Redis/ResultProcessor.cs
+2
-2
No files found.
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
3fd054da
...
@@ -118,7 +118,7 @@ public void Dispose()
...
@@ -118,7 +118,7 @@ public void Dispose()
{
{
var
ioPipe
=
_ioPipe
;
var
ioPipe
=
_ioPipe
;
_ioPipe
=
null
;
_ioPipe
=
null
;
if
(
ioPipe
!=
null
)
if
(
ioPipe
!=
null
)
{
{
Multiplexer
.
Trace
(
"Disconnecting..."
,
physicalName
);
Multiplexer
.
Trace
(
"Disconnecting..."
,
physicalName
);
try
{
ioPipe
.
Input
?.
CancelPendingRead
();
}
catch
{
}
try
{
ioPipe
.
Input
?.
CancelPendingRead
();
}
catch
{
}
...
@@ -424,7 +424,7 @@ internal void Write(RedisChannel channel)
...
@@ -424,7 +424,7 @@ internal void Write(RedisChannel channel)
internal
void
Write
(
RedisValue
value
)
internal
void
Write
(
RedisValue
value
)
{
{
switch
(
value
.
Type
)
switch
(
value
.
Type
)
{
{
case
RedisValue
.
StorageType
.
Null
:
case
RedisValue
.
StorageType
.
Null
:
WriteUnified
(
_ioPipe
.
Output
,
(
byte
[])
null
);
WriteUnified
(
_ioPipe
.
Output
,
(
byte
[])
null
);
...
@@ -681,7 +681,7 @@ internal void WriteSha1AsHex(byte[] value)
...
@@ -681,7 +681,7 @@ internal void WriteSha1AsHex(byte[] value)
{
{
writer
.
Write
(
NullBulkString
);
writer
.
Write
(
NullBulkString
);
}
}
else
if
(
value
.
Length
==
ResultProcessor
.
ScriptLoadProcessor
.
Sha1HashLength
)
else
if
(
value
.
Length
==
ResultProcessor
.
ScriptLoadProcessor
.
Sha1HashLength
)
{
{
// $40\r\n = 5
// $40\r\n = 5
// {40 bytes}\r\n = 42
// {40 bytes}\r\n = 42
...
@@ -694,7 +694,7 @@ internal void WriteSha1AsHex(byte[] value)
...
@@ -694,7 +694,7 @@ internal void WriteSha1AsHex(byte[] value)
span
[
4
]
=
(
byte
)
'\n'
;
span
[
4
]
=
(
byte
)
'\n'
;
int
offset
=
5
;
int
offset
=
5
;
for
(
int
i
=
0
;
i
<
value
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
value
.
Length
;
i
++)
{
{
var
b
=
value
[
i
];
var
b
=
value
[
i
];
span
[
offset
++]
=
ToHexNibble
(
value
[
i
]
>>
4
);
span
[
offset
++]
=
ToHexNibble
(
value
[
i
]
>>
4
);
...
@@ -790,7 +790,7 @@ private unsafe void WriteRaw(PipeWriter writer, string value, int expectedLength
...
@@ -790,7 +790,7 @@ private unsafe void WriteRaw(PipeWriter writer, string value, int expectedLength
charOffset
+=
charsUsed
;
charOffset
+=
charsUsed
;
charsRemaining
-=
charsUsed
;
charsRemaining
-=
charsUsed
;
if
(
charsRemaining
<=
0
)
if
(
charsRemaining
<=
0
)
{
{
if
(
charsRemaining
<
0
)
throw
new
InvalidOperationException
(
"String encode went negative"
);
if
(
charsRemaining
<
0
)
throw
new
InvalidOperationException
(
"String encode went negative"
);
if
(
completed
)
break
;
// fine
if
(
completed
)
break
;
// fine
...
@@ -1035,18 +1035,18 @@ void ISocketCallback.OnHeartbeat()
...
@@ -1035,18 +1035,18 @@ void ISocketCallback.OnHeartbeat()
// note: TryRead will give us back the same buffer in a tight loop
// note: TryRead will give us back the same buffer in a tight loop
// - so: only use that if we're making progress
// - so: only use that if we're making progress
if
(!(
allowSyncRead
&&
input
.
TryRead
(
out
var
readResult
)))
if
(!(
allowSyncRead
&&
input
.
TryRead
(
out
var
readResult
)))
{
{
readResult
=
await
input
.
ReadAsync
();
readResult
=
await
input
.
ReadAsync
();
}
}
var
buffer
=
readResult
.
Buffer
;
var
buffer
=
readResult
.
Buffer
;
int
handled
=
0
;
int
handled
=
0
;
if
(!
buffer
.
IsEmpty
)
if
(!
buffer
.
IsEmpty
)
{
{
handled
=
ProcessBuffer
(
ref
buffer
);
// updates buffer.Start
handled
=
ProcessBuffer
(
ref
buffer
);
// updates buffer.Start
}
}
allowSyncRead
=
handled
!=
0
;
allowSyncRead
=
handled
!=
0
;
Multiplexer
.
Trace
(
$"Processed
{
handled
}
messages"
,
physicalName
);
Multiplexer
.
Trace
(
$"Processed
{
handled
}
messages"
,
physicalName
);
...
@@ -1177,9 +1177,9 @@ private RawResult ReadBulkString(in ReadOnlySequence<byte> buffer, ref BufferRea
...
@@ -1177,9 +1177,9 @@ private RawResult ReadBulkString(in ReadOnlySequence<byte> buffer, ref BufferRea
return
new
RawResult
(
ResultType
.
BulkString
,
ReadOnlySequence
<
byte
>.
Empty
,
true
);
return
new
RawResult
(
ResultType
.
BulkString
,
ReadOnlySequence
<
byte
>.
Empty
,
true
);
}
}
if
(
reader
.
TryConsumeAsBuffer
(
bodySize
,
out
var
payload
))
if
(
reader
.
TryConsumeAsBuffer
(
bodySize
,
out
var
payload
))
{
{
switch
(
reader
.
TryConsumeCRLF
())
switch
(
reader
.
TryConsumeCRLF
())
{
{
case
ConsumeResult
.
NeedMoreData
:
case
ConsumeResult
.
NeedMoreData
:
break
;
// see NilResult below
break
;
// see NilResult below
...
@@ -1285,7 +1285,7 @@ public BufferReader(ReadOnlySequence<byte> buffer)
...
@@ -1285,7 +1285,7 @@ public BufferReader(ReadOnlySequence<byte> buffer)
/// </summary>
/// </summary>
public
ConsumeResult
TryConsumeCRLF
()
public
ConsumeResult
TryConsumeCRLF
()
{
{
switch
(
RemainingThisSpan
)
switch
(
RemainingThisSpan
)
{
{
case
0
:
case
0
:
return
ConsumeResult
.
NeedMoreData
;
return
ConsumeResult
.
NeedMoreData
;
...
@@ -1328,13 +1328,13 @@ public bool TryConsume(int count)
...
@@ -1328,13 +1328,13 @@ public bool TryConsume(int count)
return
false
;
return
false
;
}
}
readonly
ReadOnlySequence
<
byte
>
_buffer
;
private
readonly
ReadOnlySequence
<
byte
>
_buffer
;
SequencePosition
_lastSnapshotPosition
;
private
SequencePosition
_lastSnapshotPosition
;
long
_lastSnapshotBytes
;
private
long
_lastSnapshotBytes
;
// makes an internal note of where we are, as a SequencePosition; useful
// makes an internal note of where we are, as a SequencePosition; useful
// to avoid having to use buffer.Slice on huge ranges
// to avoid having to use buffer.Slice on huge ranges
SequencePosition
SnapshotPosition
()
private
SequencePosition
SnapshotPosition
()
{
{
var
consumed
=
TotalConsumed
;
var
consumed
=
TotalConsumed
;
var
delta
=
consumed
-
_lastSnapshotBytes
;
var
delta
=
consumed
-
_lastSnapshotBytes
;
...
@@ -1346,7 +1346,7 @@ SequencePosition SnapshotPosition()
...
@@ -1346,7 +1346,7 @@ SequencePosition SnapshotPosition()
}
}
public
ReadOnlySequence
<
byte
>
ConsumeAsBuffer
(
int
count
)
public
ReadOnlySequence
<
byte
>
ConsumeAsBuffer
(
int
count
)
{
{
if
(!
TryConsumeAsBuffer
(
count
,
out
var
buffer
))
throw
new
EndOfStreamException
();
if
(!
TryConsumeAsBuffer
(
count
,
out
var
buffer
))
throw
new
EndOfStreamException
();
return
buffer
;
return
buffer
;
}
}
...
@@ -1380,7 +1380,7 @@ public void Consume(int count)
...
@@ -1380,7 +1380,7 @@ public void Consume(int count)
var
span
=
reader
.
SlicedSpan
;
var
span
=
reader
.
SlicedSpan
;
if
(
haveTrailingCR
)
if
(
haveTrailingCR
)
{
{
if
(
span
[
0
]
==
'\n'
)
return
totalSkipped
-
1
;
if
(
span
[
0
]
==
'\n'
)
return
totalSkipped
-
1
;
haveTrailingCR
=
false
;
haveTrailingCR
=
false
;
}
}
...
...
StackExchange.Redis/StackExchange/Redis/RedisDatabase.cs
View file @
3fd054da
...
@@ -655,7 +655,7 @@ private sealed class KeyMigrateCommandMessage : Message.CommandKeyBase // MIGRAT
...
@@ -655,7 +655,7 @@ private sealed class KeyMigrateCommandMessage : Message.CommandKeyBase // MIGRAT
private
readonly
MigrateOptions
migrateOptions
;
private
readonly
MigrateOptions
migrateOptions
;
private
readonly
int
timeoutMilliseconds
;
private
readonly
int
timeoutMilliseconds
;
private
readonly
int
toDatabase
;
private
readonly
int
toDatabase
;
private
RedisValue
toHost
,
toPort
;
private
readonly
RedisValue
toHost
,
toPort
;
public
KeyMigrateCommandMessage
(
int
db
,
RedisKey
key
,
EndPoint
toServer
,
int
toDatabase
,
int
timeoutMilliseconds
,
MigrateOptions
migrateOptions
,
CommandFlags
flags
)
public
KeyMigrateCommandMessage
(
int
db
,
RedisKey
key
,
EndPoint
toServer
,
int
toDatabase
,
int
timeoutMilliseconds
,
MigrateOptions
migrateOptions
,
CommandFlags
flags
)
:
base
(
db
,
flags
,
RedisCommand
.
MIGRATE
,
key
)
:
base
(
db
,
flags
,
RedisCommand
.
MIGRATE
,
key
)
...
...
StackExchange.Redis/StackExchange/Redis/RedisValue.cs
View file @
3fd054da
...
@@ -608,7 +608,7 @@ private static string ToHex(ReadOnlySpan<byte> src)
...
@@ -608,7 +608,7 @@ private static string ToHex(ReadOnlySpan<byte> src)
const
string
HexValues
=
"0123456789ABCDEF"
;
const
string
HexValues
=
"0123456789ABCDEF"
;
if
(
src
.
IsEmpty
)
return
""
;
if
(
src
.
IsEmpty
)
return
""
;
var
s
=
new
string
((
char
)
0
,
src
.
Length
*
3
-
1
);
var
s
=
new
string
((
char
)
0
,
(
src
.
Length
*
3
)
-
1
);
var
dst
=
MemoryMarshal
.
AsMemory
(
s
.
AsMemory
()).
Span
;
var
dst
=
MemoryMarshal
.
AsMemory
(
s
.
AsMemory
()).
Span
;
int
i
=
0
;
int
i
=
0
;
...
...
StackExchange.Redis/StackExchange/Redis/ResultProcessor.cs
View file @
3fd054da
...
@@ -1333,7 +1333,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
...
@@ -1333,7 +1333,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
internal
sealed
class
SingleStreamProcessor
:
StreamProcessorBase
<
RedisStreamEntry
[
]>
internal
sealed
class
SingleStreamProcessor
:
StreamProcessorBase
<
RedisStreamEntry
[
]>
{
{
private
bool
skipStreamName
;
private
readonly
bool
skipStreamName
;
public
SingleStreamProcessor
(
bool
skipStreamName
=
false
)
public
SingleStreamProcessor
(
bool
skipStreamName
=
false
)
{
{
...
@@ -1454,7 +1454,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
...
@@ -1454,7 +1454,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
return
true
;
return
true
;
}
}
}
}
static
T
[]
ConvertAll
<
T
>(
ReadOnlySpan
<
RawResult
>
items
,
Func
<
RawResult
,
T
>
converter
)
private
static
T
[]
ConvertAll
<
T
>(
ReadOnlySpan
<
RawResult
>
items
,
Func
<
RawResult
,
T
>
converter
)
{
{
if
(
items
.
Length
==
0
)
return
Array
.
Empty
<
T
>();
if
(
items
.
Length
==
0
)
return
Array
.
Empty
<
T
>();
T
[]
arr
=
new
T
[
items
.
Length
];
T
[]
arr
=
new
T
[
items
.
Length
];
...
...
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