Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
3ba37089
Commit
3ba37089
authored
May 21, 2009
by
antirez
Browse files
command postprocessing implemented into RubyRedis
parent
3f32f1f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
TODO
View file @
3ba37089
BEFORE REDIS 1.0.0-rc1
* S*STORE should allow as dest key one of the source keys
* Warning if using default config, with hint about 'redis-server redis.conf'
* Add number of keys for every DB in INFO
* maxmemory support
...
...
client-libraries/ruby_2/rubyredis.rb
View file @
3ba37089
...
...
@@ -14,6 +14,35 @@ class RedisClient
"echo"
=>
true
,
"getset"
=>
true
,
"smove"
=>
true
}
ConvertToBool
=
lambda
{
|
r
|
r
==
0
?
false
:
r
}
ReplyProcessor
=
{
"exists"
=>
ConvertToBool
,
"sismember"
=>
ConvertToBool
,
"sadd"
=>
ConvertToBool
,
"srem"
=>
ConvertToBool
,
"smove"
=>
ConvertToBool
,
"move"
=>
ConvertToBool
,
"setnx"
=>
ConvertToBool
,
"del"
=>
ConvertToBool
,
"renamenx"
=>
ConvertToBool
,
"expire"
=>
ConvertToBool
,
"keys"
=>
lambda
{
|
r
|
r
.
split
(
" "
)},
"info"
=>
lambda
{
|
r
|
info
=
{}
r
.
each_line
{
|
kv
|
k
,
v
=
kv
.
split
(
':'
,
2
)
k
,
v
=
k
.
chomp
,
v
=
v
.
chomp
info
[
k
.
to_sym
]
=
v
}
info
}
}
def
convert_to_bool
(
r
)
r
==
0
?
false
:
r
end
def
initialize
(
opts
=
{})
opts
=
{
:host
=>
'localhost'
,
:port
=>
'6379'
,
:db
=>
0
}.
merge
(
opts
)
@host
=
opts
[
:host
]
...
...
@@ -52,12 +81,15 @@ class RedisClient
bulk
=
nil
argv
[
0
]
=
argv
[
0
].
to_s
.
downcase
if
BulkCommands
[
argv
[
0
]]
bulk
=
argv
[
-
1
]
bulk
=
argv
[
-
1
]
.
to_s
argv
[
-
1
]
=
bulk
.
length
end
@sock
.
write
(
argv
.
join
(
" "
)
+
"
\r\n
"
)
@sock
.
write
(
bulk
+
"
\r\n
"
)
if
bulk
read_reply
# Post process the reply if needed
processor
=
ReplyProcessor
[
argv
[
0
]]
processor
?
processor
.
call
(
read_reply
)
:
read_reply
end
def
select
(
*
args
)
...
...
redis.c
View file @
3ba37089
...
...
@@ -2973,7 +2973,7 @@ static void sinterGenericCommand(redisClient *c, robj **setskeys, int setsnum, r
robj
*
lenobj
=
NULL
,
*
dstset
=
NULL
;
int
j
,
cardinality
=
0
;
if (!dv) oom("sinterCommand");
if
(
!
dv
)
oom
(
"sinter
Generic
Command"
);
for
(
j
=
0
;
j
<
setsnum
;
j
++
)
{
robj
*
setobj
;
...
...
@@ -3151,7 +3151,6 @@ static void sunionDiffGenericCommand(redisClient *c, robj **setskeys, int setsnu
deleteKey
(
c
->
db
,
dstkey
);
dictAdd
(
c
->
db
->
dict
,
dstkey
,
dstset
);
incrRefCount
(
dstkey
);
server.dirty++;
}
/* Cleanup */
...
...
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