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
9b5f38a0
Commit
9b5f38a0
authored
Apr 14, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SSDB support
parent
4eb5318a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
6 deletions
+53
-6
SSDB.cs
StackExchange.Redis.Tests/SSDB.cs
+32
-0
StackExchange.Redis.Tests.csproj
StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj
+1
-0
TestBase.cs
StackExchange.Redis.Tests/TestBase.cs
+6
-5
CommandMap.cs
StackExchange.Redis/StackExchange/Redis/CommandMap.cs
+14
-1
No files found.
StackExchange.Redis.Tests/SSDB.cs
0 → 100644
View file @
9b5f38a0
using
NUnit.Framework
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
StackExchange.Redis.Tests
{
[
TestFixture
]
public
class
SSDB
:
TestBase
{
[
Test
]
public
void
ConnectToSSDB
()
{
var
config
=
new
ConfigurationOptions
{
EndPoints
=
{
{
"ubuntu"
,
8888
}
},
CommandMap
=
CommandMap
.
SSDB
};
RedisKey
key
=
Me
();
using
(
var
conn
=
ConnectionMultiplexer
.
Connect
(
config
))
{
var
db
=
conn
.
GetDatabase
(
0
);
db
.
KeyDelete
(
key
);
Assert
.
IsTrue
(
db
.
StringGet
(
key
).
IsNull
);
db
.
StringSet
(
key
,
"abc"
);
Assert
.
AreEqual
(
"abc"
,
(
string
)
db
.
StringGet
(
key
));
}
}
}
}
StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj
View file @
9b5f38a0
...
@@ -88,6 +88,7 @@
...
@@ -88,6 +88,7 @@
<Compile
Include=
"Scripting.cs"
/>
<Compile
Include=
"Scripting.cs"
/>
<Compile
Include=
"Secure.cs"
/>
<Compile
Include=
"Secure.cs"
/>
<Compile
Include=
"Sets.cs"
/>
<Compile
Include=
"Sets.cs"
/>
<Compile
Include=
"SSDB.cs"
/>
<Compile
Include=
"SSL.cs"
/>
<Compile
Include=
"SSL.cs"
/>
<Compile
Include=
"TaskTests.cs"
/>
<Compile
Include=
"TaskTests.cs"
/>
<Compile
Include=
"TestBase.cs"
/>
<Compile
Include=
"TestBase.cs"
/>
...
...
StackExchange.Redis.Tests/TestBase.cs
View file @
9b5f38a0
...
@@ -145,7 +145,8 @@ protected IServer GetServer(ConnectionMultiplexer muxer)
...
@@ -145,7 +145,8 @@ protected IServer GetServer(ConnectionMultiplexer muxer)
protected
virtual
ConnectionMultiplexer
Create
(
protected
virtual
ConnectionMultiplexer
Create
(
string
clientName
=
null
,
int
?
syncTimeout
=
null
,
bool
?
allowAdmin
=
null
,
int
?
keepAlive
=
null
,
string
clientName
=
null
,
int
?
syncTimeout
=
null
,
bool
?
allowAdmin
=
null
,
int
?
keepAlive
=
null
,
int
?
connectTimeout
=
null
,
string
password
=
null
,
string
tieBreaker
=
null
,
TextWriter
log
=
null
,
int
?
connectTimeout
=
null
,
string
password
=
null
,
string
tieBreaker
=
null
,
TextWriter
log
=
null
,
bool
fail
=
true
,
string
[]
disabledCommands
=
null
,
bool
checkConnect
=
true
,
bool
pause
=
true
,
string
failMessage
=
null
,
bool
fail
=
true
,
string
[]
disabledCommands
=
null
,
string
[]
enabledCommands
=
null
,
bool
checkConnect
=
true
,
bool
pause
=
true
,
string
failMessage
=
null
,
string
channelPrefix
=
null
,
bool
useSharedSocketManager
=
true
,
Proxy
?
proxy
=
null
)
string
channelPrefix
=
null
,
bool
useSharedSocketManager
=
true
,
Proxy
?
proxy
=
null
)
{
{
if
(
pause
)
Thread
.
Sleep
(
500
);
// get a lot of glitches when hammering new socket creations etc; pace it out a bit
if
(
pause
)
Thread
.
Sleep
(
500
);
// get a lot of glitches when hammering new socket creations etc; pace it out a bit
...
@@ -153,10 +154,10 @@ protected IServer GetServer(ConnectionMultiplexer muxer)
...
@@ -153,10 +154,10 @@ protected IServer GetServer(ConnectionMultiplexer muxer)
var
config
=
ConfigurationOptions
.
Parse
(
configuration
);
var
config
=
ConfigurationOptions
.
Parse
(
configuration
);
if
(
disabledCommands
!=
null
&&
disabledCommands
.
Length
!=
0
)
if
(
disabledCommands
!=
null
&&
disabledCommands
.
Length
!=
0
)
{
{
var
map
=
new
Dictionary
<
string
,
string
>(
);
config
.
CommandMap
=
CommandMap
.
Create
(
new
HashSet
<
string
>(
disabledCommands
),
false
);
foreach
(
var
cmd
in
disabledCommands
)
}
else
if
(
enabledCommands
!=
null
&&
enabledCommands
.
Length
!=
0
)
map
[
cmd
]
=
null
;
{
config
.
CommandMap
=
CommandMap
.
Create
(
map
);
config
.
CommandMap
=
CommandMap
.
Create
(
new
HashSet
<
string
>(
enabledCommands
),
true
);
}
}
if
(
Debugger
.
IsAttached
)
if
(
Debugger
.
IsAttached
)
...
...
StackExchange.Redis/StackExchange/Redis/CommandMap.cs
View file @
9b5f38a0
...
@@ -38,7 +38,13 @@ private static readonly CommandMap
...
@@ -38,7 +38,13 @@ private static readonly CommandMap
RedisCommand
.
BGREWRITEAOF
,
RedisCommand
.
BGSAVE
,
RedisCommand
.
CLIENT
,
RedisCommand
.
CLUSTER
,
RedisCommand
.
CONFIG
,
RedisCommand
.
DBSIZE
,
RedisCommand
.
BGREWRITEAOF
,
RedisCommand
.
BGSAVE
,
RedisCommand
.
CLIENT
,
RedisCommand
.
CLUSTER
,
RedisCommand
.
CONFIG
,
RedisCommand
.
DBSIZE
,
RedisCommand
.
DEBUG
,
RedisCommand
.
FLUSHALL
,
RedisCommand
.
FLUSHDB
,
RedisCommand
.
INFO
,
RedisCommand
.
LASTSAVE
,
RedisCommand
.
MONITOR
,
RedisCommand
.
SAVE
,
RedisCommand
.
DEBUG
,
RedisCommand
.
FLUSHALL
,
RedisCommand
.
FLUSHDB
,
RedisCommand
.
INFO
,
RedisCommand
.
LASTSAVE
,
RedisCommand
.
MONITOR
,
RedisCommand
.
SAVE
,
RedisCommand
.
SHUTDOWN
,
RedisCommand
.
SLAVEOF
,
RedisCommand
.
SLOWLOG
,
RedisCommand
.
SYNC
,
RedisCommand
.
TIME
RedisCommand
.
SHUTDOWN
,
RedisCommand
.
SLAVEOF
,
RedisCommand
.
SLOWLOG
,
RedisCommand
.
SYNC
,
RedisCommand
.
TIME
});
}),
ssdb
=
Create
(
new
HashSet
<
string
>
{
// see http://www.ideawu.com/ssdb/docs/redis-to-ssdb.html
"ping"
,
"get"
,
"set"
,
"del"
,
"incr"
,
"incrby"
,
"mget"
,
"mset"
,
"keys"
,
"getset"
,
"setnx"
,
"hget"
,
"hset"
,
"hdel"
,
"hincrby"
,
"hkeys"
,
"hvals"
,
"hmget"
,
"hmset"
,
"hlen"
,
"zscore"
,
"zadd"
,
"zrem"
,
"zrange"
,
"zrangebyscore"
,
"zincrby"
,
"zdecrby"
,
"zcard"
,
"llen"
,
"lpush"
,
"rpush"
,
"lpop"
,
"rpop"
,
"lrange"
,
"lindex"
},
true
);
private
readonly
byte
[][]
map
;
private
readonly
byte
[][]
map
;
internal
CommandMap
(
byte
[][]
map
)
internal
CommandMap
(
byte
[][]
map
)
...
@@ -56,6 +62,13 @@ internal CommandMap(byte[][] map)
...
@@ -56,6 +62,13 @@ internal CommandMap(byte[][] map)
/// <remarks>https://github.com/twitter/twemproxy/blob/master/notes/redis.md</remarks>
/// <remarks>https://github.com/twitter/twemproxy/blob/master/notes/redis.md</remarks>
public
static
CommandMap
Twemproxy
{
get
{
return
twemproxy
;
}
}
public
static
CommandMap
Twemproxy
{
get
{
return
twemproxy
;
}
}
/// <summary>
/// The commands available to <a href="ssdb">http://www.ideawu.com/ssdb/</a>
/// </summary>
/// <remarks>http://www.ideawu.com/ssdb/docs/redis-to-ssdb.html</remarks>
public
static
CommandMap
SSDB
{
get
{
return
ssdb
;
}
}
/// <summary>
/// <summary>
/// Create a new CommandMap, customizing some commands
/// Create a new CommandMap, customizing some commands
/// </summary>
/// </summary>
...
...
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