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
e6a3e65b
Commit
e6a3e65b
authored
Apr 04, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Line endings fix: partial files
parent
20fa2587
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
61 deletions
+61
-61
KeysAndValues.cs
StackExchange.Redis.Tests/KeysAndValues.cs
+2
-2
RedisServer.cs
StackExchange.Redis/StackExchange/Redis/RedisServer.cs
+19
-19
RedisTransaction.cs
StackExchange.Redis/StackExchange/Redis/RedisTransaction.cs
+21
-21
ResultBox.cs
StackExchange.Redis/StackExchange/Redis/ResultBox.cs
+19
-19
No files found.
StackExchange.Redis.Tests/KeysAndValues.cs
View file @
e6a3e65b
...
...
@@ -68,7 +68,7 @@ private void CheckSame(RedisValue x, RedisValue y)
Assert
.
True
(
y
.
Equals
(
x
));
Assert
.
True
(
x
.
GetHashCode
()
==
y
.
GetHashCode
());
}
private
void
CheckNotSame
(
RedisValue
x
,
RedisValue
y
)
{
Assert
.
False
(
Equals
(
x
,
y
));
...
...
@@ -92,7 +92,7 @@ private void CheckNotNull(RedisValue value)
CheckNotSame
(
value
,
(
string
)
null
);
CheckNotSame
(
value
,
(
byte
[])
null
);
}
private
void
CheckNull
(
RedisValue
value
)
{
Assert
.
True
(
value
.
IsNull
);
...
...
StackExchange.Redis/StackExchange/Redis/RedisServer.cs
View file @
e6a3e65b
...
...
@@ -30,8 +30,8 @@ internal RedisServer(ConnectionMultiplexer multiplexer, ServerEndPoint server, o
public
bool
AllowSlaveWrites
{
get
=>
server
.
AllowSlaveWrites
;
set
=>
server
.
AllowSlaveWrites
=
value
;
get
=>
server
.
AllowSlaveWrites
;
set
=>
server
.
AllowSlaveWrites
=
value
;
}
public
ServerType
ServerType
=>
server
.
ServerType
;
...
...
@@ -61,7 +61,7 @@ public Task<long> ClientKillAsync(long? id = null, ClientType? clientType = null
var
msg
=
GetClientKillMessage
(
endpoint
,
id
,
clientType
,
skipMe
,
flags
);
return
ExecuteAsync
(
msg
,
ResultProcessor
.
Int64
);
}
private
Message
GetClientKillMessage
(
EndPoint
endpoint
,
long
?
id
,
ClientType
?
clientType
,
bool
skipMe
,
CommandFlags
flags
)
{
var
parts
=
new
List
<
RedisValue
>(
9
)
...
...
@@ -193,7 +193,7 @@ public Task ConfigSetAsync(RedisValue setting, RedisValue value, CommandFlags fl
ExecuteSync
(
Message
.
Create
(-
1
,
flags
|
CommandFlags
.
FireAndForget
,
RedisCommand
.
CONFIG
,
RedisLiterals
.
GET
,
setting
),
ResultProcessor
.
AutoConfigure
);
return
task
;
}
public
long
DatabaseSize
(
int
database
=
0
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
var
msg
=
Message
.
Create
(
database
,
flags
,
RedisCommand
.
DBSIZE
);
...
...
@@ -211,7 +211,7 @@ public RedisValue Echo(RedisValue message, CommandFlags flags)
var
msg
=
Message
.
Create
(-
1
,
flags
,
RedisCommand
.
ECHO
,
message
);
return
ExecuteSync
(
msg
,
ResultProcessor
.
RedisValue
);
}
public
Task
<
RedisValue
>
EchoAsync
(
RedisValue
message
,
CommandFlags
flags
)
{
var
msg
=
Message
.
Create
(-
1
,
flags
,
RedisCommand
.
ECHO
,
message
);
...
...
@@ -223,7 +223,7 @@ public void FlushAllDatabases(CommandFlags flags = CommandFlags.None)
var
msg
=
Message
.
Create
(-
1
,
flags
,
RedisCommand
.
FLUSHALL
);
ExecuteSync
(
msg
,
ResultProcessor
.
DemandOK
);
}
public
Task
FlushAllDatabasesAsync
(
CommandFlags
flags
=
CommandFlags
.
None
)
{
var
msg
=
Message
.
Create
(-
1
,
flags
,
RedisCommand
.
FLUSHALL
);
...
...
@@ -318,7 +318,7 @@ public void MakeMaster(ReplicationChangeOptions options, TextWriter log = null)
{
multiplexer
.
MakeMaster
(
server
,
options
,
log
);
}
public
void
Save
(
SaveType
type
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
var
msg
=
GetSaveMessage
(
type
,
flags
);
...
...
@@ -379,16 +379,16 @@ public Task<byte[]> ScriptLoadAsync(string script, CommandFlags flags = CommandF
{
var
msg
=
new
RedisDatabase
.
ScriptLoadMessage
(
flags
,
script
);
return
ExecuteAsync
(
msg
,
ResultProcessor
.
ScriptLoad
);
}
public
LoadedLuaScript
ScriptLoad
(
LuaScript
script
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
script
.
Load
(
this
,
flags
);
}
public
Task
<
LoadedLuaScript
>
ScriptLoadAsync
(
LuaScript
script
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
script
.
LoadAsync
(
this
,
flags
);
}
public
LoadedLuaScript
ScriptLoad
(
LuaScript
script
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
script
.
Load
(
this
,
flags
);
}
public
Task
<
LoadedLuaScript
>
ScriptLoadAsync
(
LuaScript
script
,
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
script
.
LoadAsync
(
this
,
flags
);
}
public
void
Shutdown
(
ShutdownMode
shutdownMode
=
ShutdownMode
.
Default
,
CommandFlags
flags
=
CommandFlags
.
None
)
...
...
@@ -677,7 +677,7 @@ public static RedisValue Encode(byte[] value)
}
return
result
;
}
public
static
RedisValue
Hash
(
string
value
)
{
if
(
value
==
null
)
return
default
(
RedisValue
);
...
...
@@ -724,7 +724,7 @@ protected override Message CreateMessage(long cursor)
}
}
}
protected
override
ResultProcessor
<
ScanResult
>
Processor
=>
processor
;
public
static
readonly
ResultProcessor
<
ScanResult
>
processor
=
new
KeysResultProcessor
();
...
...
StackExchange.Redis/StackExchange/Redis/RedisTransaction.cs
View file @
e6a3e65b
...
...
@@ -107,7 +107,7 @@ internal override T ExecuteSync<T>(Message message, ResultProcessor<T> processor
{
throw
new
NotSupportedException
(
"ExecuteSync cannot be used inside a transaction"
);
}
private
Message
CreateMessage
(
CommandFlags
flags
,
out
ResultProcessor
<
bool
>
processor
)
{
var
work
=
pending
;
...
...
@@ -121,14 +121,14 @@ private Message CreateMessage(CommandFlags flags, out ResultProcessor<bool> proc
{
processor
=
null
;
return
null
;
// they won't notice if we don't do anything...
}
}
processor
=
ResultProcessor
.
DemandPONG
;
return
Message
.
Create
(-
1
,
flags
,
RedisCommand
.
PING
);
}
processor
=
TransactionProcessor
.
Default
;
return
new
TransactionMessage
(
Database
,
flags
,
cond
,
work
);
}
private
class
QueuedMessage
:
Message
{
public
Message
Wrapped
{
get
;
}
...
...
@@ -142,13 +142,13 @@ public QueuedMessage(Message message) : base(message.Db, message.Flags | Command
public
bool
WasQueued
{
get
=>
wasQueued
;
get
=>
wasQueued
;
set
=>
wasQueued
=
value
;
}
internal
override
void
WriteImpl
(
PhysicalConnection
physical
)
{
Wrapped
.
WriteImpl
(
physical
);
Wrapped
.
WriteImpl
(
physical
);
Wrapped
.
SetRequestSent
();
}
}
...
...
@@ -161,16 +161,16 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
{
if
(
result
.
Type
==
ResultType
.
SimpleString
&&
result
.
IsEqual
(
QUEUED
))
{
if
(
message
is
QueuedMessage
q
)
{
q
.
WasQueued
=
true
;
}
if
(
message
is
QueuedMessage
q
)
{
q
.
WasQueued
=
true
;
}
return
true
;
}
return
false
;
}
}
private
class
TransactionMessage
:
Message
,
IMultiMessage
{
private
static
readonly
ConditionResult
[]
NixConditions
=
new
ConditionResult
[
0
];
...
...
@@ -193,7 +193,7 @@ public override void AppendStormLog(StringBuilder sb)
if
(
conditions
.
Length
!=
0
)
sb
.
Append
(
", "
).
Append
(
conditions
.
Length
).
Append
(
" conditions"
);
sb
.
Append
(
", "
).
Append
(
InnerOperations
.
Length
).
Append
(
" operations"
);
}
public
override
int
GetHashSlot
(
ServerSelectionStrategy
serverSelectionStrategy
)
{
int
slot
=
ServerSelectionStrategy
.
NoSlot
;
...
...
@@ -373,23 +373,23 @@ private bool AreAllConditionsSatisfied(ConnectionMultiplexer multiplexer)
private
class
TransactionProcessor
:
ResultProcessor
<
bool
>
{
public
static
readonly
TransactionProcessor
Default
=
new
TransactionProcessor
();
public
static
readonly
TransactionProcessor
Default
=
new
TransactionProcessor
();
public
override
bool
SetResult
(
PhysicalConnection
connection
,
Message
message
,
RawResult
result
)
{
if
(
result
.
IsError
&&
message
is
TransactionMessage
tran
)
{
string
error
=
result
.
GetString
();
var
bridge
=
connection
.
Bridge
;
foreach
(
var
op
in
tran
.
InnerOperations
)
{
ServerFail
(
op
.
Wrapped
,
error
);
bridge
.
CompleteSyncOrAsync
(
op
.
Wrapped
);
{
string
error
=
result
.
GetString
();
var
bridge
=
connection
.
Bridge
;
foreach
(
var
op
in
tran
.
InnerOperations
)
{
ServerFail
(
op
.
Wrapped
,
error
);
bridge
.
CompleteSyncOrAsync
(
op
.
Wrapped
);
}
}
return
base
.
SetResult
(
connection
,
message
,
result
);
}
protected
override
bool
SetResultCore
(
PhysicalConnection
connection
,
Message
message
,
RawResult
result
)
{
if
(
message
is
TransactionMessage
tran
)
...
...
StackExchange.Redis/StackExchange/Redis/ResultBox.cs
View file @
e6a3e65b
...
...
@@ -7,7 +7,7 @@ namespace StackExchange.Redis
{
internal
abstract
partial
class
ResultBox
{
protected
Exception
exception
;
protected
Exception
exception
;
public
void
SetException
(
Exception
exception
)
{
...
...
@@ -32,16 +32,16 @@ protected static void IncrementAllocationCount()
static
partial
void
OnAllocated
();
}
internal
sealed
class
ResultBox
<
T
>
:
ResultBox
{
private
static
readonly
ResultBox
<
T
>[]
store
=
new
ResultBox
<
T
>[
64
];
private
object
stateOrCompletionSource
;
private
T
value
;
private
T
value
;
public
ResultBox
(
object
stateOrCompletionSource
)
{
this
.
stateOrCompletionSource
=
stateOrCompletionSource
;
this
.
stateOrCompletionSource
=
stateOrCompletionSource
;
}
public
object
AsyncState
=>
...
...
@@ -78,11 +78,11 @@ public static void UnwrapAndRecycle(ResultBox<T> box, bool recycle, out T value,
exception
=
box
.
exception
;
box
.
value
=
default
(
T
);
box
.
exception
=
null
;
if
(
recycle
)
{
for
(
int
i
=
0
;
i
<
store
.
Length
;
i
++)
{
if
(
Interlocked
.
CompareExchange
(
ref
store
[
i
],
box
,
null
)
==
null
)
return
;
if
(
recycle
)
{
for
(
int
i
=
0
;
i
<
store
.
Length
;
i
++)
{
if
(
Interlocked
.
CompareExchange
(
ref
store
[
i
],
box
,
null
)
==
null
)
return
;
}
}
}
...
...
@@ -96,17 +96,17 @@ public void SetResult(T value)
public
override
bool
TryComplete
(
bool
isAsync
)
{
if
(
stateOrCompletionSource
is
TaskCompletionSource
<
T
>
tcs
)
{
{
#if !PLAT_SAFE_CONTINUATIONS // we don't need to check in this scenario
if
(
isAsync
||
TaskSource
.
IsSyncSafe
(
tcs
.
Task
))
if
(
isAsync
||
TaskSource
.
IsSyncSafe
(
tcs
.
Task
))
#endif
{
UnwrapAndRecycle
(
this
,
true
,
out
T
val
,
out
Exception
ex
);
if
(
ex
==
null
)
{
tcs
.
TrySetResult
(
val
);
}
if
(
ex
==
null
)
{
tcs
.
TrySetResult
(
val
);
}
else
{
if
(
ex
is
TaskCanceledException
)
tcs
.
TrySetCanceled
();
...
...
@@ -116,12 +116,12 @@ public override bool TryComplete(bool isAsync)
GC
.
SuppressFinalize
(
tcs
.
Task
);
}
return
true
;
}
}
#if !PLAT_SAFE_CONTINUATIONS
else
{
// looks like continuations; push to async to preserve the reader thread
return
false
;
}
}
#endif
}
else
...
...
@@ -138,7 +138,7 @@ public override bool TryComplete(bool isAsync)
private
void
Reset
(
object
stateOrCompletionSource
)
{
value
=
default
(
T
);
exception
=
null
;
exception
=
null
;
this
.
stateOrCompletionSource
=
stateOrCompletionSource
;
}
...
...
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