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
c002a00e
Commit
c002a00e
authored
Mar 28, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate BookSleeve "Scripting" suite; fix "eval inside transaction" bug
parent
6c191d56
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
431 additions
and
331 deletions
+431
-331
Program.cs
MigratedBookSleeveTestSuite/Program.cs
+5
-5
Scripting.cs
MigratedBookSleeveTestSuite/Scripting.cs
+374
-322
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+17
-4
RedisResult.cs
StackExchange.Redis/StackExchange/Redis/RedisResult.cs
+19
-0
RedisTransaction.cs
StackExchange.Redis/StackExchange/Redis/RedisTransaction.cs
+16
-0
No files found.
MigratedBookSleeveTestSuite/Program.cs
View file @
c002a00e
...
...
@@ -188,11 +188,11 @@ where Attribute.IsDefined(method, typeof(TestAttribute))
}
Console
.
WriteLine
(
"Passed: {0}; Failed: {1}"
,
pass
,
fail
);
foreach
(
var
msg
in
epicFail
)
Console
.
WriteLine
(
msg
);
#if DEBUG
Console
.
WriteLine
();
Console
.
WriteLine
(
"Callbacks: {0:###,###,##0} sync, {1:###,###,##0} async"
,
BookSleeve
.
RedisConnectionBase
.
AllSyncCallbacks
,
BookSleeve
.
RedisConnectionBase
.
AllAsyncCallbacks
);
#endif
//
#if DEBUG
//
Console.WriteLine();
//
Console.WriteLine("Callbacks: {0:###,###,##0} sync, {1:###,###,##0} async",
//
BookSleeve.RedisConnectionBase.AllSyncCallbacks, BookSleeve.RedisConnectionBase.AllAsyncCallbacks);
//
#endif
}
}
...
...
MigratedBookSleeveTestSuite/Scripting.cs
View file @
c002a00e
This diff is collapsed.
Click to expand it.
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
c002a00e
...
...
@@ -273,9 +273,18 @@ internal Message GetSelectDatabaseCommand(int targetDatabase, Message message)
}
return
null
;
}
if
(
message
.
Command
==
RedisCommand
.
SELECT
)
{
// this could come from an EVAL/EVALSHA inside a transaction, for example; we'll accept it
bridge
.
Trace
(
"Switching database: "
+
targetDatabase
);
currentDatabase
=
targetDatabase
;
return
null
;
}
if
(
TransactionActive
)
{
// should never see this, since the API doesn't allow it; thus not too worried about ExceptionFactory
throw
new
RedisCommandException
(
"Multiple databases inside a transaction are not currently supported"
+
targetDatabase
);
throw
new
RedisCommandException
(
"Multiple databases inside a transaction are not currently supported
:
"
+
targetDatabase
);
}
if
(
available
!=
0
&&
targetDatabase
>=
available
)
// we positively know it is out of range
...
...
@@ -284,12 +293,16 @@ internal Message GetSelectDatabaseCommand(int targetDatabase, Message message)
}
bridge
.
Trace
(
"Switching database: "
+
targetDatabase
);
currentDatabase
=
targetDatabase
;
return
targetDatabase
<
DefaultRedisDatabaseCount
?
ReusableChangeDatabaseCommands
[
targetDatabase
]
// 0-15 by default
:
Message
.
Create
(
targetDatabase
,
CommandFlags
.
FireAndForget
,
RedisCommand
.
SELECT
);
return
GetSelectDatabaseCommand
(
targetDatabase
);
}
return
null
;
}
internal
static
Message
GetSelectDatabaseCommand
(
int
targetDatabase
)
{
return
targetDatabase
<
DefaultRedisDatabaseCount
?
ReusableChangeDatabaseCommands
[
targetDatabase
]
// 0-15 by default
:
Message
.
Create
(
targetDatabase
,
CommandFlags
.
FireAndForget
,
RedisCommand
.
SELECT
);
}
internal
int
GetSentAwaitingResponseCount
()
{
...
...
StackExchange.Redis/StackExchange/Redis/RedisResult.cs
View file @
c002a00e
...
...
@@ -7,6 +7,7 @@ namespace StackExchange.Redis
/// </summary>
public
abstract
class
RedisResult
{
// internally, this is very similar to RawResult, except it is designed to be usable
// outside of the IO-processing pipeline: the buffers are standalone, etc
...
...
@@ -42,6 +43,11 @@ internal static RedisResult TryCreate(PhysicalConnection connection, RawResult r
}
}
/// <summary>
/// Indicates whether this result was a null result
/// </summary>
public
abstract
bool
IsNull
{
get
;
}
/// <summary>
/// Interprets the result as a String
/// </summary>
...
...
@@ -168,6 +174,10 @@ internal static RedisResult TryCreate(PhysicalConnection connection, RawResult r
internal
abstract
string
[]
AsStringArray
();
private
sealed
class
ArrayRedisResult
:
RedisResult
{
public
override
bool
IsNull
{
get
{
return
value
==
null
;
}
}
private
readonly
RedisResult
[]
value
;
public
ArrayRedisResult
(
RedisResult
[]
value
)
{
...
...
@@ -275,6 +285,10 @@ public ErrorRedisResult(string value)
if
(
value
==
null
)
throw
new
ArgumentNullException
(
"value"
);
this
.
value
=
value
;
}
public
override
bool
IsNull
{
get
{
return
value
==
null
;
}
}
public
override
string
ToString
()
{
return
value
;
}
internal
override
bool
AsBoolean
()
{
throw
new
RedisServerException
(
value
);
}
...
...
@@ -326,6 +340,11 @@ public SingleRedisResult(RedisValue value)
this
.
value
=
value
;
}
public
override
bool
IsNull
{
get
{
return
value
.
IsNull
;
}
}
public
override
string
ToString
()
{
return
value
.
ToString
();
}
internal
override
bool
AsBoolean
()
{
return
(
bool
)
value
;
}
...
...
StackExchange.Redis/StackExchange/Redis/RedisTransaction.cs
View file @
c002a00e
...
...
@@ -86,6 +86,22 @@ internal override Task<T> ExecuteAsync<T>(Message message, ResultProcessor<T> pr
// store it, and return the task of the *outer* command
// (there is no task for the inner command)
(
pending
??
(
pending
=
new
List
<
QueuedMessage
>())).
Add
(
queued
);
switch
(
message
.
Command
)
{
case
RedisCommand
.
EVAL
:
case
RedisCommand
.
EVALSHA
:
// people can do very naughty things in an EVAL
// including change the DB; change it back to what we
// think it should be!
var
sel
=
PhysicalConnection
.
GetSelectDatabaseCommand
(
message
.
Db
);
queued
=
new
QueuedMessage
(
sel
);
wasQueued
=
ResultBox
<
bool
>.
Get
(
null
);
queued
.
SetSource
(
wasQueued
,
QueuedProcessor
.
Default
);
pending
.
Add
(
queued
);
break
;
}
return
task
;
}
...
...
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