Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
554bd0e7
Commit
554bd0e7
authored
Jul 26, 2015
by
antirez
Browse files
RDMF: use client instead of redisClient, like Disque.
parent
424fe9af
Changes
29
Expand all
Hide whitespace changes
Inline
Side-by-side
src/server.h
View file @
554bd0e7
This diff is collapsed.
Click to expand it.
src/slowlog.c
View file @
554bd0e7
...
@@ -127,7 +127,7 @@ void slowlogReset(void) {
...
@@ -127,7 +127,7 @@ void slowlogReset(void) {
/* The SLOWLOG command. Implements all the subcommands needed to handle the
/* The SLOWLOG command. Implements all the subcommands needed to handle the
* Redis slow log. */
* Redis slow log. */
void
slowlogCommand
(
redisC
lient
*
c
)
{
void
slowlogCommand
(
c
lient
*
c
)
{
if
(
c
->
argc
==
2
&&
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"reset"
))
{
if
(
c
->
argc
==
2
&&
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"reset"
))
{
slowlogReset
();
slowlogReset
();
addReply
(
c
,
shared
.
ok
);
addReply
(
c
,
shared
.
ok
);
...
...
src/slowlog.h
View file @
554bd0e7
...
@@ -44,4 +44,4 @@ void slowlogInit(void);
...
@@ -44,4 +44,4 @@ void slowlogInit(void);
void
slowlogPushEntryIfNeeded
(
robj
**
argv
,
int
argc
,
long
long
duration
);
void
slowlogPushEntryIfNeeded
(
robj
**
argv
,
int
argc
,
long
long
duration
);
/* Exported commands */
/* Exported commands */
void
slowlogCommand
(
redisC
lient
*
c
);
void
slowlogCommand
(
c
lient
*
c
);
src/sort.c
View file @
554bd0e7
...
@@ -186,7 +186,7 @@ int sortCompare(const void *s1, const void *s2) {
...
@@ -186,7 +186,7 @@ int sortCompare(const void *s1, const void *s2) {
/* The SORT command is the most complex command in Redis. Warning: this code
/* The SORT command is the most complex command in Redis. Warning: this code
* is optimized for speed and a bit less for readability */
* is optimized for speed and a bit less for readability */
void
sortCommand
(
redisC
lient
*
c
)
{
void
sortCommand
(
c
lient
*
c
)
{
list
*
operations
;
list
*
operations
;
unsigned
int
outputlen
=
0
;
unsigned
int
outputlen
=
0
;
int
desc
=
0
,
alpha
=
0
;
int
desc
=
0
,
alpha
=
0
;
...
...
src/t_hash.c
View file @
554bd0e7
...
@@ -415,7 +415,7 @@ robj *hashTypeCurrentObject(hashTypeIterator *hi, int what) {
...
@@ -415,7 +415,7 @@ robj *hashTypeCurrentObject(hashTypeIterator *hi, int what) {
return
dst
;
return
dst
;
}
}
robj
*
hashTypeLookupWriteOrCreate
(
redisC
lient
*
c
,
robj
*
key
)
{
robj
*
hashTypeLookupWriteOrCreate
(
c
lient
*
c
,
robj
*
key
)
{
robj
*
o
=
lookupKeyWrite
(
c
->
db
,
key
);
robj
*
o
=
lookupKeyWrite
(
c
->
db
,
key
);
if
(
o
==
NULL
)
{
if
(
o
==
NULL
)
{
o
=
createHashObject
();
o
=
createHashObject
();
...
@@ -483,7 +483,7 @@ void hashTypeConvert(robj *o, int enc) {
...
@@ -483,7 +483,7 @@ void hashTypeConvert(robj *o, int enc) {
* Hash type commands
* Hash type commands
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
void
hsetCommand
(
redisC
lient
*
c
)
{
void
hsetCommand
(
c
lient
*
c
)
{
int
update
;
int
update
;
robj
*
o
;
robj
*
o
;
...
@@ -497,7 +497,7 @@ void hsetCommand(redisClient *c) {
...
@@ -497,7 +497,7 @@ void hsetCommand(redisClient *c) {
server
.
dirty
++
;
server
.
dirty
++
;
}
}
void
hsetnxCommand
(
redisC
lient
*
c
)
{
void
hsetnxCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
...
@@ -514,7 +514,7 @@ void hsetnxCommand(redisClient *c) {
...
@@ -514,7 +514,7 @@ void hsetnxCommand(redisClient *c) {
}
}
}
}
void
hmsetCommand
(
redisC
lient
*
c
)
{
void
hmsetCommand
(
c
lient
*
c
)
{
int
i
;
int
i
;
robj
*
o
;
robj
*
o
;
...
@@ -535,7 +535,7 @@ void hmsetCommand(redisClient *c) {
...
@@ -535,7 +535,7 @@ void hmsetCommand(redisClient *c) {
server
.
dirty
++
;
server
.
dirty
++
;
}
}
void
hincrbyCommand
(
redisC
lient
*
c
)
{
void
hincrbyCommand
(
c
lient
*
c
)
{
long
long
value
,
incr
,
oldvalue
;
long
long
value
,
incr
,
oldvalue
;
robj
*
o
,
*
current
,
*
new
;
robj
*
o
,
*
current
,
*
new
;
...
@@ -569,7 +569,7 @@ void hincrbyCommand(redisClient *c) {
...
@@ -569,7 +569,7 @@ void hincrbyCommand(redisClient *c) {
server
.
dirty
++
;
server
.
dirty
++
;
}
}
void
hincrbyfloatCommand
(
redisC
lient
*
c
)
{
void
hincrbyfloatCommand
(
c
lient
*
c
)
{
double
long
value
,
incr
;
double
long
value
,
incr
;
robj
*
o
,
*
current
,
*
new
,
*
aux
;
robj
*
o
,
*
current
,
*
new
,
*
aux
;
...
@@ -605,7 +605,7 @@ void hincrbyfloatCommand(redisClient *c) {
...
@@ -605,7 +605,7 @@ void hincrbyfloatCommand(redisClient *c) {
decrRefCount
(
new
);
decrRefCount
(
new
);
}
}
static
void
addHashFieldToReply
(
redisC
lient
*
c
,
robj
*
o
,
robj
*
field
)
{
static
void
addHashFieldToReply
(
c
lient
*
c
,
robj
*
o
,
robj
*
field
)
{
int
ret
;
int
ret
;
if
(
o
==
NULL
)
{
if
(
o
==
NULL
)
{
...
@@ -644,7 +644,7 @@ static void addHashFieldToReply(redisClient *c, robj *o, robj *field) {
...
@@ -644,7 +644,7 @@ static void addHashFieldToReply(redisClient *c, robj *o, robj *field) {
}
}
}
}
void
hgetCommand
(
redisC
lient
*
c
)
{
void
hgetCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
...
@@ -653,7 +653,7 @@ void hgetCommand(redisClient *c) {
...
@@ -653,7 +653,7 @@ void hgetCommand(redisClient *c) {
addHashFieldToReply
(
c
,
o
,
c
->
argv
[
2
]);
addHashFieldToReply
(
c
,
o
,
c
->
argv
[
2
]);
}
}
void
hmgetCommand
(
redisC
lient
*
c
)
{
void
hmgetCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
int
i
;
int
i
;
...
@@ -671,7 +671,7 @@ void hmgetCommand(redisClient *c) {
...
@@ -671,7 +671,7 @@ void hmgetCommand(redisClient *c) {
}
}
}
}
void
hdelCommand
(
redisC
lient
*
c
)
{
void
hdelCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
int
j
,
deleted
=
0
,
keyremoved
=
0
;
int
j
,
deleted
=
0
,
keyremoved
=
0
;
...
@@ -699,7 +699,7 @@ void hdelCommand(redisClient *c) {
...
@@ -699,7 +699,7 @@ void hdelCommand(redisClient *c) {
addReplyLongLong
(
c
,
deleted
);
addReplyLongLong
(
c
,
deleted
);
}
}
void
hlenCommand
(
redisC
lient
*
c
)
{
void
hlenCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
...
@@ -708,7 +708,7 @@ void hlenCommand(redisClient *c) {
...
@@ -708,7 +708,7 @@ void hlenCommand(redisClient *c) {
addReplyLongLong
(
c
,
hashTypeLength
(
o
));
addReplyLongLong
(
c
,
hashTypeLength
(
o
));
}
}
void
hstrlenCommand
(
redisC
lient
*
c
)
{
void
hstrlenCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
...
@@ -716,7 +716,7 @@ void hstrlenCommand(redisClient *c) {
...
@@ -716,7 +716,7 @@ void hstrlenCommand(redisClient *c) {
addReplyLongLong
(
c
,
hashTypeGetValueLength
(
o
,
c
->
argv
[
2
]));
addReplyLongLong
(
c
,
hashTypeGetValueLength
(
o
,
c
->
argv
[
2
]));
}
}
static
void
addHashIteratorCursorToReply
(
redisC
lient
*
c
,
hashTypeIterator
*
hi
,
int
what
)
{
static
void
addHashIteratorCursorToReply
(
c
lient
*
c
,
hashTypeIterator
*
hi
,
int
what
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
unsigned
char
*
vstr
=
NULL
;
unsigned
char
*
vstr
=
NULL
;
unsigned
int
vlen
=
UINT_MAX
;
unsigned
int
vlen
=
UINT_MAX
;
...
@@ -740,7 +740,7 @@ static void addHashIteratorCursorToReply(redisClient *c, hashTypeIterator *hi, i
...
@@ -740,7 +740,7 @@ static void addHashIteratorCursorToReply(redisClient *c, hashTypeIterator *hi, i
}
}
}
}
void
genericHgetallCommand
(
redisC
lient
*
c
,
int
flags
)
{
void
genericHgetallCommand
(
c
lient
*
c
,
int
flags
)
{
robj
*
o
;
robj
*
o
;
hashTypeIterator
*
hi
;
hashTypeIterator
*
hi
;
int
multiplier
=
0
;
int
multiplier
=
0
;
...
@@ -771,19 +771,19 @@ void genericHgetallCommand(redisClient *c, int flags) {
...
@@ -771,19 +771,19 @@ void genericHgetallCommand(redisClient *c, int flags) {
redisAssert
(
count
==
length
);
redisAssert
(
count
==
length
);
}
}
void
hkeysCommand
(
redisC
lient
*
c
)
{
void
hkeysCommand
(
c
lient
*
c
)
{
genericHgetallCommand
(
c
,
REDIS_HASH_KEY
);
genericHgetallCommand
(
c
,
REDIS_HASH_KEY
);
}
}
void
hvalsCommand
(
redisC
lient
*
c
)
{
void
hvalsCommand
(
c
lient
*
c
)
{
genericHgetallCommand
(
c
,
REDIS_HASH_VALUE
);
genericHgetallCommand
(
c
,
REDIS_HASH_VALUE
);
}
}
void
hgetallCommand
(
redisC
lient
*
c
)
{
void
hgetallCommand
(
c
lient
*
c
)
{
genericHgetallCommand
(
c
,
REDIS_HASH_KEY
|
REDIS_HASH_VALUE
);
genericHgetallCommand
(
c
,
REDIS_HASH_KEY
|
REDIS_HASH_VALUE
);
}
}
void
hexistsCommand
(
redisC
lient
*
c
)
{
void
hexistsCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
...
@@ -791,7 +791,7 @@ void hexistsCommand(redisClient *c) {
...
@@ -791,7 +791,7 @@ void hexistsCommand(redisClient *c) {
addReply
(
c
,
hashTypeExists
(
o
,
c
->
argv
[
2
])
?
shared
.
cone
:
shared
.
czero
);
addReply
(
c
,
hashTypeExists
(
o
,
c
->
argv
[
2
])
?
shared
.
cone
:
shared
.
czero
);
}
}
void
hscanCommand
(
redisC
lient
*
c
)
{
void
hscanCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
unsigned
long
cursor
;
unsigned
long
cursor
;
...
...
src/t_list.c
View file @
554bd0e7
...
@@ -194,7 +194,7 @@ void listTypeConvert(robj *subject, int enc) {
...
@@ -194,7 +194,7 @@ void listTypeConvert(robj *subject, int enc) {
* List Commands
* List Commands
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
void
pushGenericCommand
(
redisC
lient
*
c
,
int
where
)
{
void
pushGenericCommand
(
c
lient
*
c
,
int
where
)
{
int
j
,
waiting
=
0
,
pushed
=
0
;
int
j
,
waiting
=
0
,
pushed
=
0
;
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
...
@@ -224,15 +224,15 @@ void pushGenericCommand(redisClient *c, int where) {
...
@@ -224,15 +224,15 @@ void pushGenericCommand(redisClient *c, int where) {
server
.
dirty
+=
pushed
;
server
.
dirty
+=
pushed
;
}
}
void
lpushCommand
(
redisC
lient
*
c
)
{
void
lpushCommand
(
c
lient
*
c
)
{
pushGenericCommand
(
c
,
REDIS_HEAD
);
pushGenericCommand
(
c
,
REDIS_HEAD
);
}
}
void
rpushCommand
(
redisC
lient
*
c
)
{
void
rpushCommand
(
c
lient
*
c
)
{
pushGenericCommand
(
c
,
REDIS_TAIL
);
pushGenericCommand
(
c
,
REDIS_TAIL
);
}
}
void
pushxGenericCommand
(
redisC
lient
*
c
,
robj
*
refval
,
robj
*
val
,
int
where
)
{
void
pushxGenericCommand
(
c
lient
*
c
,
robj
*
refval
,
robj
*
val
,
int
where
)
{
robj
*
subject
;
robj
*
subject
;
listTypeIterator
*
iter
;
listTypeIterator
*
iter
;
listTypeEntry
entry
;
listTypeEntry
entry
;
...
@@ -275,17 +275,17 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
...
@@ -275,17 +275,17 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
addReplyLongLong
(
c
,
listTypeLength
(
subject
));
addReplyLongLong
(
c
,
listTypeLength
(
subject
));
}
}
void
lpushxCommand
(
redisC
lient
*
c
)
{
void
lpushxCommand
(
c
lient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_HEAD
);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_HEAD
);
}
}
void
rpushxCommand
(
redisC
lient
*
c
)
{
void
rpushxCommand
(
c
lient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_TAIL
);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_TAIL
);
}
}
void
linsertCommand
(
redisC
lient
*
c
)
{
void
linsertCommand
(
c
lient
*
c
)
{
c
->
argv
[
4
]
=
tryObjectEncoding
(
c
->
argv
[
4
]);
c
->
argv
[
4
]
=
tryObjectEncoding
(
c
->
argv
[
4
]);
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"after"
)
==
0
)
{
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"after"
)
==
0
)
{
pushxGenericCommand
(
c
,
c
->
argv
[
3
],
c
->
argv
[
4
],
REDIS_TAIL
);
pushxGenericCommand
(
c
,
c
->
argv
[
3
],
c
->
argv
[
4
],
REDIS_TAIL
);
...
@@ -296,13 +296,13 @@ void linsertCommand(redisClient *c) {
...
@@ -296,13 +296,13 @@ void linsertCommand(redisClient *c) {
}
}
}
}
void
llenCommand
(
redisC
lient
*
c
)
{
void
llenCommand
(
c
lient
*
c
)
{
robj
*
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
);
robj
*
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
addReplyLongLong
(
c
,
listTypeLength
(
o
));
addReplyLongLong
(
c
,
listTypeLength
(
o
));
}
}
void
lindexCommand
(
redisC
lient
*
c
)
{
void
lindexCommand
(
c
lient
*
c
)
{
robj
*
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
);
robj
*
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
long
index
;
long
index
;
...
@@ -329,7 +329,7 @@ void lindexCommand(redisClient *c) {
...
@@ -329,7 +329,7 @@ void lindexCommand(redisClient *c) {
}
}
}
}
void
lsetCommand
(
redisC
lient
*
c
)
{
void
lsetCommand
(
c
lient
*
c
)
{
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nokeyerr
);
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nokeyerr
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
long
index
;
long
index
;
...
@@ -355,7 +355,7 @@ void lsetCommand(redisClient *c) {
...
@@ -355,7 +355,7 @@ void lsetCommand(redisClient *c) {
}
}
}
}
void
popGenericCommand
(
redisC
lient
*
c
,
int
where
)
{
void
popGenericCommand
(
c
lient
*
c
,
int
where
)
{
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
);
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
...
@@ -378,15 +378,15 @@ void popGenericCommand(redisClient *c, int where) {
...
@@ -378,15 +378,15 @@ void popGenericCommand(redisClient *c, int where) {
}
}
}
}
void
lpopCommand
(
redisC
lient
*
c
)
{
void
lpopCommand
(
c
lient
*
c
)
{
popGenericCommand
(
c
,
REDIS_HEAD
);
popGenericCommand
(
c
,
REDIS_HEAD
);
}
}
void
rpopCommand
(
redisC
lient
*
c
)
{
void
rpopCommand
(
c
lient
*
c
)
{
popGenericCommand
(
c
,
REDIS_TAIL
);
popGenericCommand
(
c
,
REDIS_TAIL
);
}
}
void
lrangeCommand
(
redisC
lient
*
c
)
{
void
lrangeCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
long
start
,
end
,
llen
,
rangelen
;
long
start
,
end
,
llen
,
rangelen
;
...
@@ -432,7 +432,7 @@ void lrangeCommand(redisClient *c) {
...
@@ -432,7 +432,7 @@ void lrangeCommand(redisClient *c) {
}
}
}
}
void
ltrimCommand
(
redisC
lient
*
c
)
{
void
ltrimCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
long
start
,
end
,
llen
,
ltrim
,
rtrim
;
long
start
,
end
,
llen
,
ltrim
,
rtrim
;
...
@@ -478,7 +478,7 @@ void ltrimCommand(redisClient *c) {
...
@@ -478,7 +478,7 @@ void ltrimCommand(redisClient *c) {
addReply
(
c
,
shared
.
ok
);
addReply
(
c
,
shared
.
ok
);
}
}
void
lremCommand
(
redisC
lient
*
c
)
{
void
lremCommand
(
c
lient
*
c
)
{
robj
*
subject
,
*
obj
;
robj
*
subject
,
*
obj
;
obj
=
c
->
argv
[
3
];
obj
=
c
->
argv
[
3
];
long
toremove
;
long
toremove
;
...
@@ -533,7 +533,7 @@ void lremCommand(redisClient *c) {
...
@@ -533,7 +533,7 @@ void lremCommand(redisClient *c) {
* as well. This command was originally proposed by Ezra Zygmuntowicz.
* as well. This command was originally proposed by Ezra Zygmuntowicz.
*/
*/
void
rpoplpushHandlePush
(
redisC
lient
*
c
,
robj
*
dstkey
,
robj
*
dstobj
,
robj
*
value
)
{
void
rpoplpushHandlePush
(
c
lient
*
c
,
robj
*
dstkey
,
robj
*
dstobj
,
robj
*
value
)
{
/* Create the list if the key does not exist */
/* Create the list if the key does not exist */
if
(
!
dstobj
)
{
if
(
!
dstobj
)
{
dstobj
=
createQuicklistObject
();
dstobj
=
createQuicklistObject
();
...
@@ -548,7 +548,7 @@ void rpoplpushHandlePush(redisClient *c, robj *dstkey, robj *dstobj, robj *value
...
@@ -548,7 +548,7 @@ void rpoplpushHandlePush(redisClient *c, robj *dstkey, robj *dstobj, robj *value
addReplyBulk
(
c
,
value
);
addReplyBulk
(
c
,
value
);
}
}
void
rpoplpushCommand
(
redisC
lient
*
c
)
{
void
rpoplpushCommand
(
c
lient
*
c
)
{
robj
*
sobj
,
*
value
;
robj
*
sobj
,
*
value
;
if
((
sobj
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
if
((
sobj
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
checkType
(
c
,
sobj
,
REDIS_LIST
))
return
;
checkType
(
c
,
sobj
,
REDIS_LIST
))
return
;
...
@@ -608,7 +608,7 @@ void rpoplpushCommand(redisClient *c) {
...
@@ -608,7 +608,7 @@ void rpoplpushCommand(redisClient *c) {
/* Set a client in blocking mode for the specified key, with the specified
/* Set a client in blocking mode for the specified key, with the specified
* timeout */
* timeout */
void
blockForKeys
(
redisC
lient
*
c
,
robj
**
keys
,
int
numkeys
,
mstime_t
timeout
,
robj
*
target
)
{
void
blockForKeys
(
c
lient
*
c
,
robj
**
keys
,
int
numkeys
,
mstime_t
timeout
,
robj
*
target
)
{
dictEntry
*
de
;
dictEntry
*
de
;
list
*
l
;
list
*
l
;
int
j
;
int
j
;
...
@@ -643,7 +643,7 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, mstime_t timeout, ro
...
@@ -643,7 +643,7 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, mstime_t timeout, ro
/* Unblock a client that's waiting in a blocking operation such as BLPOP.
/* Unblock a client that's waiting in a blocking operation such as BLPOP.
* You should never call this function directly, but unblockClient() instead. */
* You should never call this function directly, but unblockClient() instead. */
void
unblockClientWaitingData
(
redisC
lient
*
c
)
{
void
unblockClientWaitingData
(
c
lient
*
c
)
{
dictEntry
*
de
;
dictEntry
*
de
;
dictIterator
*
di
;
dictIterator
*
di
;
list
*
l
;
list
*
l
;
...
@@ -721,7 +721,7 @@ void signalListAsReady(redisDb *db, robj *key) {
...
@@ -721,7 +721,7 @@ void signalListAsReady(redisDb *db, robj *key) {
* should be undone as the client was not served: This only happens for
* should be undone as the client was not served: This only happens for
* BRPOPLPUSH that fails to push the value to the destination key as it is
* BRPOPLPUSH that fails to push the value to the destination key as it is
* of the wrong type. */
* of the wrong type. */
int
serveClientBlockedOnList
(
redisC
lient
*
receiver
,
robj
*
key
,
robj
*
dstkey
,
redisDb
*
db
,
robj
*
value
,
int
where
)
int
serveClientBlockedOnList
(
c
lient
*
receiver
,
robj
*
key
,
robj
*
dstkey
,
redisDb
*
db
,
robj
*
value
,
int
where
)
{
{
robj
*
argv
[
3
];
robj
*
argv
[
3
];
...
@@ -815,7 +815,7 @@ void handleClientsBlockedOnLists(void) {
...
@@ -815,7 +815,7 @@ void handleClientsBlockedOnLists(void) {
while
(
numclients
--
)
{
while
(
numclients
--
)
{
listNode
*
clientnode
=
listFirst
(
clients
);
listNode
*
clientnode
=
listFirst
(
clients
);
redisC
lient
*
receiver
=
clientnode
->
value
;
c
lient
*
receiver
=
clientnode
->
value
;
robj
*
dstkey
=
receiver
->
bpop
.
target
;
robj
*
dstkey
=
receiver
->
bpop
.
target
;
int
where
=
(
receiver
->
lastcmd
&&
int
where
=
(
receiver
->
lastcmd
&&
receiver
->
lastcmd
->
proc
==
blpopCommand
)
?
receiver
->
lastcmd
->
proc
==
blpopCommand
)
?
...
@@ -863,7 +863,7 @@ void handleClientsBlockedOnLists(void) {
...
@@ -863,7 +863,7 @@ void handleClientsBlockedOnLists(void) {
}
}
/* Blocking RPOP/LPOP */
/* Blocking RPOP/LPOP */
void
blockingPopGenericCommand
(
redisC
lient
*
c
,
int
where
)
{
void
blockingPopGenericCommand
(
c
lient
*
c
,
int
where
)
{
robj
*
o
;
robj
*
o
;
mstime_t
timeout
;
mstime_t
timeout
;
int
j
;
int
j
;
...
@@ -919,15 +919,15 @@ void blockingPopGenericCommand(redisClient *c, int where) {
...
@@ -919,15 +919,15 @@ void blockingPopGenericCommand(redisClient *c, int where) {
blockForKeys
(
c
,
c
->
argv
+
1
,
c
->
argc
-
2
,
timeout
,
NULL
);
blockForKeys
(
c
,
c
->
argv
+
1
,
c
->
argc
-
2
,
timeout
,
NULL
);
}
}
void
blpopCommand
(
redisC
lient
*
c
)
{
void
blpopCommand
(
c
lient
*
c
)
{
blockingPopGenericCommand
(
c
,
REDIS_HEAD
);
blockingPopGenericCommand
(
c
,
REDIS_HEAD
);
}
}
void
brpopCommand
(
redisC
lient
*
c
)
{
void
brpopCommand
(
c
lient
*
c
)
{
blockingPopGenericCommand
(
c
,
REDIS_TAIL
);
blockingPopGenericCommand
(
c
,
REDIS_TAIL
);
}
}
void
brpoplpushCommand
(
redisC
lient
*
c
)
{
void
brpoplpushCommand
(
c
lient
*
c
)
{
mstime_t
timeout
;
mstime_t
timeout
;
if
(
getTimeoutFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
timeout
,
UNIT_SECONDS
)
if
(
getTimeoutFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
timeout
,
UNIT_SECONDS
)
...
...
src/t_set.c
View file @
554bd0e7
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
* Set Commands
* Set Commands
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
void
sunionDiffGenericCommand
(
redisC
lient
*
c
,
robj
**
setkeys
,
int
setnum
,
void
sunionDiffGenericCommand
(
c
lient
*
c
,
robj
**
setkeys
,
int
setnum
,
robj
*
dstkey
,
int
op
);
robj
*
dstkey
,
int
op
);
/* Factory method to return a set that *can* hold "value". When the object has
/* Factory method to return a set that *can* hold "value". When the object has
...
@@ -269,7 +269,7 @@ void setTypeConvert(robj *setobj, int enc) {
...
@@ -269,7 +269,7 @@ void setTypeConvert(robj *setobj, int enc) {
}
}
}
}
void
saddCommand
(
redisC
lient
*
c
)
{
void
saddCommand
(
c
lient
*
c
)
{
robj
*
set
;
robj
*
set
;
int
j
,
added
=
0
;
int
j
,
added
=
0
;
...
@@ -296,7 +296,7 @@ void saddCommand(redisClient *c) {
...
@@ -296,7 +296,7 @@ void saddCommand(redisClient *c) {
addReplyLongLong
(
c
,
added
);
addReplyLongLong
(
c
,
added
);
}
}
void
sremCommand
(
redisC
lient
*
c
)
{
void
sremCommand
(
c
lient
*
c
)
{
robj
*
set
;
robj
*
set
;
int
j
,
deleted
=
0
,
keyremoved
=
0
;
int
j
,
deleted
=
0
,
keyremoved
=
0
;
...
@@ -324,7 +324,7 @@ void sremCommand(redisClient *c) {
...
@@ -324,7 +324,7 @@ void sremCommand(redisClient *c) {
addReplyLongLong
(
c
,
deleted
);
addReplyLongLong
(
c
,
deleted
);
}
}
void
smoveCommand
(
redisC
lient
*
c
)
{
void
smoveCommand
(
c
lient
*
c
)
{
robj
*
srcset
,
*
dstset
,
*
ele
;
robj
*
srcset
,
*
dstset
,
*
ele
;
srcset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
srcset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
dstset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
dstset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
...
@@ -377,7 +377,7 @@ void smoveCommand(redisClient *c) {
...
@@ -377,7 +377,7 @@ void smoveCommand(redisClient *c) {
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
cone
);
}
}
void
sismemberCommand
(
redisC
lient
*
c
)
{
void
sismemberCommand
(
c
lient
*
c
)
{
robj
*
set
;
robj
*
set
;
if
((
set
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
set
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
...
@@ -390,7 +390,7 @@ void sismemberCommand(redisClient *c) {
...
@@ -390,7 +390,7 @@ void sismemberCommand(redisClient *c) {
addReply
(
c
,
shared
.
czero
);
addReply
(
c
,
shared
.
czero
);
}
}
void
scardCommand
(
redisC
lient
*
c
)
{
void
scardCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
...
@@ -407,7 +407,7 @@ void scardCommand(redisClient *c) {
...
@@ -407,7 +407,7 @@ void scardCommand(redisClient *c) {
* implementation for more info. */
* implementation for more info. */
#define SPOP_MOVE_STRATEGY_MUL 5
#define SPOP_MOVE_STRATEGY_MUL 5
void
spopWithCountCommand
(
redisC
lient
*
c
)
{
void
spopWithCountCommand
(
c
lient
*
c
)
{
long
l
;
long
l
;
unsigned
long
count
,
size
;
unsigned
long
count
,
size
;
robj
*
set
;
robj
*
set
;
...
@@ -556,7 +556,7 @@ void spopWithCountCommand(redisClient *c) {
...
@@ -556,7 +556,7 @@ void spopWithCountCommand(redisClient *c) {
preventCommandPropagation
(
c
);
preventCommandPropagation
(
c
);
}
}
void
spopCommand
(
redisC
lient
*
c
)
{
void
spopCommand
(
c
lient
*
c
)
{
robj
*
set
,
*
ele
,
*
aux
;
robj
*
set
,
*
ele
,
*
aux
;
int64_t
llele
;
int64_t
llele
;
int
encoding
;
int
encoding
;
...
@@ -616,7 +616,7 @@ void spopCommand(redisClient *c) {
...
@@ -616,7 +616,7 @@ void spopCommand(redisClient *c) {
* implementation for more info. */
* implementation for more info. */
#define SRANDMEMBER_SUB_STRATEGY_MUL 3
#define SRANDMEMBER_SUB_STRATEGY_MUL 3
void
srandmemberWithCountCommand
(
redisC
lient
*
c
)
{
void
srandmemberWithCountCommand
(
c
lient
*
c
)
{
long
l
;
long
l
;
unsigned
long
count
,
size
;
unsigned
long
count
,
size
;
int
uniq
=
1
;
int
uniq
=
1
;
...
@@ -749,7 +749,7 @@ void srandmemberWithCountCommand(redisClient *c) {
...
@@ -749,7 +749,7 @@ void srandmemberWithCountCommand(redisClient *c) {
}
}
}
}
void
srandmemberCommand
(
redisC
lient
*
c
)
{
void
srandmemberCommand
(
c
lient
*
c
)
{
robj
*
set
,
*
ele
;
robj
*
set
,
*
ele
;
int64_t
llele
;
int64_t
llele
;
int
encoding
;
int
encoding
;
...
@@ -785,7 +785,7 @@ int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
...
@@ -785,7 +785,7 @@ int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
return
(
o2
?
setTypeSize
(
o2
)
:
0
)
-
(
o1
?
setTypeSize
(
o1
)
:
0
);
return
(
o2
?
setTypeSize
(
o2
)
:
0
)
-
(
o1
?
setTypeSize
(
o1
)
:
0
);
}
}
void
sinterGenericCommand
(
redisC
lient
*
c
,
robj
**
setkeys
,
void
sinterGenericCommand
(
c
lient
*
c
,
robj
**
setkeys
,
unsigned
long
setnum
,
robj
*
dstkey
)
{
unsigned
long
setnum
,
robj
*
dstkey
)
{
robj
**
sets
=
zmalloc
(
sizeof
(
robj
*
)
*
setnum
);
robj
**
sets
=
zmalloc
(
sizeof
(
robj
*
)
*
setnum
);
setTypeIterator
*
si
;
setTypeIterator
*
si
;
...
@@ -921,11 +921,11 @@ void sinterGenericCommand(redisClient *c, robj **setkeys,
...
@@ -921,11 +921,11 @@ void sinterGenericCommand(redisClient *c, robj **setkeys,
zfree
(
sets
);
zfree
(
sets
);
}
}
void
sinterCommand
(
redisC
lient
*
c
)
{
void
sinterCommand
(
c
lient
*
c
)
{
sinterGenericCommand
(
c
,
c
->
argv
+
1
,
c
->
argc
-
1
,
NULL
);
sinterGenericCommand
(
c
,
c
->
argv
+
1
,
c
->
argc
-
1
,
NULL
);
}
}
void
sinterstoreCommand
(
redisC
lient
*
c
)
{
void
sinterstoreCommand
(
c
lient
*
c
)
{
sinterGenericCommand
(
c
,
c
->
argv
+
2
,
c
->
argc
-
2
,
c
->
argv
[
1
]);
sinterGenericCommand
(
c
,
c
->
argv
+
2
,
c
->
argc
-
2
,
c
->
argv
[
1
]);
}
}
...
@@ -933,7 +933,7 @@ void sinterstoreCommand(redisClient *c) {
...
@@ -933,7 +933,7 @@ void sinterstoreCommand(redisClient *c) {
#define REDIS_OP_DIFF 1
#define REDIS_OP_DIFF 1
#define REDIS_OP_INTER 2
#define REDIS_OP_INTER 2
void
sunionDiffGenericCommand
(
redisC
lient
*
c
,
robj
**
setkeys
,
int
setnum
,
void
sunionDiffGenericCommand
(
c
lient
*
c
,
robj
**
setkeys
,
int
setnum
,
robj
*
dstkey
,
int
op
)
{
robj
*
dstkey
,
int
op
)
{
robj
**
sets
=
zmalloc
(
sizeof
(
robj
*
)
*
setnum
);
robj
**
sets
=
zmalloc
(
sizeof
(
robj
*
)
*
setnum
);
setTypeIterator
*
si
;
setTypeIterator
*
si
;
...
@@ -1092,23 +1092,23 @@ void sunionDiffGenericCommand(redisClient *c, robj **setkeys, int setnum,
...
@@ -1092,23 +1092,23 @@ void sunionDiffGenericCommand(redisClient *c, robj **setkeys, int setnum,
zfree
(
sets
);
zfree
(
sets
);
}
}
void
sunionCommand
(
redisC
lient
*
c
)
{
void
sunionCommand
(
c
lient
*
c
)
{
sunionDiffGenericCommand
(
c
,
c
->
argv
+
1
,
c
->
argc
-
1
,
NULL
,
REDIS_OP_UNION
);
sunionDiffGenericCommand
(
c
,
c
->
argv
+
1
,
c
->
argc
-
1
,
NULL
,
REDIS_OP_UNION
);
}
}
void
sunionstoreCommand
(
redisC
lient
*
c
)
{
void
sunionstoreCommand
(
c
lient
*
c
)
{
sunionDiffGenericCommand
(
c
,
c
->
argv
+
2
,
c
->
argc
-
2
,
c
->
argv
[
1
],
REDIS_OP_UNION
);
sunionDiffGenericCommand
(
c
,
c
->
argv
+
2
,
c
->
argc
-
2
,
c
->
argv
[
1
],
REDIS_OP_UNION
);
}
}
void
sdiffCommand
(
redisC
lient
*
c
)
{
void
sdiffCommand
(
c
lient
*
c
)
{
sunionDiffGenericCommand
(
c
,
c
->
argv
+
1
,
c
->
argc
-
1
,
NULL
,
REDIS_OP_DIFF
);
sunionDiffGenericCommand
(
c
,
c
->
argv
+
1
,
c
->
argc
-
1
,
NULL
,
REDIS_OP_DIFF
);
}
}
void
sdiffstoreCommand
(
redisC
lient
*
c
)
{
void
sdiffstoreCommand
(
c
lient
*
c
)
{
sunionDiffGenericCommand
(
c
,
c
->
argv
+
2
,
c
->
argc
-
2
,
c
->
argv
[
1
],
REDIS_OP_DIFF
);
sunionDiffGenericCommand
(
c
,
c
->
argv
+
2
,
c
->
argc
-
2
,
c
->
argv
[
1
],
REDIS_OP_DIFF
);
}
}
void
sscanCommand
(
redisC
lient
*
c
)
{
void
sscanCommand
(
c
lient
*
c
)
{
robj
*
set
;
robj
*
set
;
unsigned
long
cursor
;
unsigned
long
cursor
;
...
...
src/t_string.c
View file @
554bd0e7
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
* String Commands
* String Commands
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
static
int
checkStringLength
(
redisC
lient
*
c
,
long
long
size
)
{
static
int
checkStringLength
(
c
lient
*
c
,
long
long
size
)
{
if
(
size
>
512
*
1024
*
1024
)
{
if
(
size
>
512
*
1024
*
1024
)
{
addReplyError
(
c
,
"string exceeds maximum allowed size (512MB)"
);
addReplyError
(
c
,
"string exceeds maximum allowed size (512MB)"
);
return
REDIS_ERR
;
return
REDIS_ERR
;
...
@@ -64,7 +64,7 @@ static int checkStringLength(redisClient *c, long long size) {
...
@@ -64,7 +64,7 @@ static int checkStringLength(redisClient *c, long long size) {
#define REDIS_SET_EX (1<<2)
/* Set if time in seconds is given */
#define REDIS_SET_EX (1<<2)
/* Set if time in seconds is given */
#define REDIS_SET_PX (1<<3)
/* Set if time in ms in given */
#define REDIS_SET_PX (1<<3)
/* Set if time in ms in given */
void
setGenericCommand
(
redisC
lient
*
c
,
int
flags
,
robj
*
key
,
robj
*
val
,
robj
*
expire
,
int
unit
,
robj
*
ok_reply
,
robj
*
abort_reply
)
{
void
setGenericCommand
(
c
lient
*
c
,
int
flags
,
robj
*
key
,
robj
*
val
,
robj
*
expire
,
int
unit
,
robj
*
ok_reply
,
robj
*
abort_reply
)
{
long
long
milliseconds
=
0
;
/* initialized to avoid any harmness warning */
long
long
milliseconds
=
0
;
/* initialized to avoid any harmness warning */
if
(
expire
)
{
if
(
expire
)
{
...
@@ -93,7 +93,7 @@ void setGenericCommand(redisClient *c, int flags, robj *key, robj *val, robj *ex
...
@@ -93,7 +93,7 @@ void setGenericCommand(redisClient *c, int flags, robj *key, robj *val, robj *ex
}
}
/* SET key value [NX] [XX] [EX <seconds>] [PX <milliseconds>] */
/* SET key value [NX] [XX] [EX <seconds>] [PX <milliseconds>] */
void
setCommand
(
redisC
lient
*
c
)
{
void
setCommand
(
c
lient
*
c
)
{
int
j
;
int
j
;
robj
*
expire
=
NULL
;
robj
*
expire
=
NULL
;
int
unit
=
UNIT_SECONDS
;
int
unit
=
UNIT_SECONDS
;
...
@@ -139,22 +139,22 @@ void setCommand(redisClient *c) {
...
@@ -139,22 +139,22 @@ void setCommand(redisClient *c) {
setGenericCommand
(
c
,
flags
,
c
->
argv
[
1
],
c
->
argv
[
2
],
expire
,
unit
,
NULL
,
NULL
);
setGenericCommand
(
c
,
flags
,
c
->
argv
[
1
],
c
->
argv
[
2
],
expire
,
unit
,
NULL
,
NULL
);
}
}
void
setnxCommand
(
redisC
lient
*
c
)
{
void
setnxCommand
(
c
lient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
setGenericCommand
(
c
,
REDIS_SET_NX
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
,
0
,
shared
.
cone
,
shared
.
czero
);
setGenericCommand
(
c
,
REDIS_SET_NX
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
,
0
,
shared
.
cone
,
shared
.
czero
);
}
}
void
setexCommand
(
redisC
lient
*
c
)
{
void
setexCommand
(
c
lient
*
c
)
{
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
setGenericCommand
(
c
,
REDIS_SET_NO_FLAGS
,
c
->
argv
[
1
],
c
->
argv
[
3
],
c
->
argv
[
2
],
UNIT_SECONDS
,
NULL
,
NULL
);
setGenericCommand
(
c
,
REDIS_SET_NO_FLAGS
,
c
->
argv
[
1
],
c
->
argv
[
3
],
c
->
argv
[
2
],
UNIT_SECONDS
,
NULL
,
NULL
);
}
}
void
psetexCommand
(
redisC
lient
*
c
)
{
void
psetexCommand
(
c
lient
*
c
)
{
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
setGenericCommand
(
c
,
REDIS_SET_NO_FLAGS
,
c
->
argv
[
1
],
c
->
argv
[
3
],
c
->
argv
[
2
],
UNIT_MILLISECONDS
,
NULL
,
NULL
);
setGenericCommand
(
c
,
REDIS_SET_NO_FLAGS
,
c
->
argv
[
1
],
c
->
argv
[
3
],
c
->
argv
[
2
],
UNIT_MILLISECONDS
,
NULL
,
NULL
);
}
}
int
getGenericCommand
(
redisC
lient
*
c
)
{
int
getGenericCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
)
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
)
...
@@ -169,11 +169,11 @@ int getGenericCommand(redisClient *c) {
...
@@ -169,11 +169,11 @@ int getGenericCommand(redisClient *c) {
}
}
}
}
void
getCommand
(
redisC
lient
*
c
)
{
void
getCommand
(
c
lient
*
c
)
{
getGenericCommand
(
c
);
getGenericCommand
(
c
);
}
}
void
getsetCommand
(
redisC
lient
*
c
)
{
void
getsetCommand
(
c
lient
*
c
)
{
if
(
getGenericCommand
(
c
)
==
REDIS_ERR
)
return
;
if
(
getGenericCommand
(
c
)
==
REDIS_ERR
)
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
setKey
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
setKey
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
...
@@ -181,7 +181,7 @@ void getsetCommand(redisClient *c) {
...
@@ -181,7 +181,7 @@ void getsetCommand(redisClient *c) {
server
.
dirty
++
;
server
.
dirty
++
;
}
}
void
setrangeCommand
(
redisC
lient
*
c
)
{
void
setrangeCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
long
offset
;
long
offset
;
sds
value
=
c
->
argv
[
3
]
->
ptr
;
sds
value
=
c
->
argv
[
3
]
->
ptr
;
...
@@ -241,7 +241,7 @@ void setrangeCommand(redisClient *c) {
...
@@ -241,7 +241,7 @@ void setrangeCommand(redisClient *c) {
addReplyLongLong
(
c
,
sdslen
(
o
->
ptr
));
addReplyLongLong
(
c
,
sdslen
(
o
->
ptr
));
}
}
void
getrangeCommand
(
redisC
lient
*
c
)
{
void
getrangeCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
long
long
start
,
end
;
long
long
start
,
end
;
char
*
str
,
llbuf
[
32
];
char
*
str
,
llbuf
[
32
];
...
@@ -278,7 +278,7 @@ void getrangeCommand(redisClient *c) {
...
@@ -278,7 +278,7 @@ void getrangeCommand(redisClient *c) {
}
}
}
}
void
mgetCommand
(
redisC
lient
*
c
)
{
void
mgetCommand
(
c
lient
*
c
)
{
int
j
;
int
j
;
addReplyMultiBulkLen
(
c
,
c
->
argc
-
1
);
addReplyMultiBulkLen
(
c
,
c
->
argc
-
1
);
...
@@ -296,7 +296,7 @@ void mgetCommand(redisClient *c) {
...
@@ -296,7 +296,7 @@ void mgetCommand(redisClient *c) {
}
}
}
}
void
msetGenericCommand
(
redisC
lient
*
c
,
int
nx
)
{
void
msetGenericCommand
(
c
lient
*
c
,
int
nx
)
{
int
j
,
busykeys
=
0
;
int
j
,
busykeys
=
0
;
if
((
c
->
argc
%
2
)
==
0
)
{
if
((
c
->
argc
%
2
)
==
0
)
{
...
@@ -326,15 +326,15 @@ void msetGenericCommand(redisClient *c, int nx) {
...
@@ -326,15 +326,15 @@ void msetGenericCommand(redisClient *c, int nx) {
addReply
(
c
,
nx
?
shared
.
cone
:
shared
.
ok
);
addReply
(
c
,
nx
?
shared
.
cone
:
shared
.
ok
);
}
}
void
msetCommand
(
redisC
lient
*
c
)
{
void
msetCommand
(
c
lient
*
c
)
{
msetGenericCommand
(
c
,
0
);
msetGenericCommand
(
c
,
0
);
}
}
void
msetnxCommand
(
redisC
lient
*
c
)
{
void
msetnxCommand
(
c
lient
*
c
)
{
msetGenericCommand
(
c
,
1
);
msetGenericCommand
(
c
,
1
);
}
}
void
incrDecrCommand
(
redisC
lient
*
c
,
long
long
incr
)
{
void
incrDecrCommand
(
c
lient
*
c
,
long
long
incr
)
{
long
long
value
,
oldvalue
;
long
long
value
,
oldvalue
;
robj
*
o
,
*
new
;
robj
*
o
,
*
new
;
...
@@ -372,29 +372,29 @@ void incrDecrCommand(redisClient *c, long long incr) {
...
@@ -372,29 +372,29 @@ void incrDecrCommand(redisClient *c, long long incr) {
addReply
(
c
,
shared
.
crlf
);
addReply
(
c
,
shared
.
crlf
);
}
}
void
incrCommand
(
redisC
lient
*
c
)
{
void
incrCommand
(
c
lient
*
c
)
{
incrDecrCommand
(
c
,
1
);
incrDecrCommand
(
c
,
1
);
}
}
void
decrCommand
(
redisC
lient
*
c
)
{
void
decrCommand
(
c
lient
*
c
)
{
incrDecrCommand
(
c
,
-
1
);
incrDecrCommand
(
c
,
-
1
);
}
}
void
incrbyCommand
(
redisC
lient
*
c
)
{
void
incrbyCommand
(
c
lient
*
c
)
{
long
long
incr
;
long
long
incr
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
incrDecrCommand
(
c
,
incr
);
incrDecrCommand
(
c
,
incr
);
}
}
void
decrbyCommand
(
redisC
lient
*
c
)
{
void
decrbyCommand
(
c
lient
*
c
)
{
long
long
incr
;
long
long
incr
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
incrDecrCommand
(
c
,
-
incr
);
incrDecrCommand
(
c
,
-
incr
);
}
}
void
incrbyfloatCommand
(
redisC
lient
*
c
)
{
void
incrbyfloatCommand
(
c
lient
*
c
)
{
long
double
incr
,
value
;
long
double
incr
,
value
;
robj
*
o
,
*
new
,
*
aux
;
robj
*
o
,
*
new
,
*
aux
;
...
@@ -428,7 +428,7 @@ void incrbyfloatCommand(redisClient *c) {
...
@@ -428,7 +428,7 @@ void incrbyfloatCommand(redisClient *c) {
rewriteClientCommandArgument
(
c
,
2
,
new
);
rewriteClientCommandArgument
(
c
,
2
,
new
);
}
}
void
appendCommand
(
redisC
lient
*
c
)
{
void
appendCommand
(
c
lient
*
c
)
{
size_t
totlen
;
size_t
totlen
;
robj
*
o
,
*
append
;
robj
*
o
,
*
append
;
...
@@ -461,7 +461,7 @@ void appendCommand(redisClient *c) {
...
@@ -461,7 +461,7 @@ void appendCommand(redisClient *c) {
addReplyLongLong
(
c
,
totlen
);
addReplyLongLong
(
c
,
totlen
);
}
}
void
strlenCommand
(
redisC
lient
*
c
)
{
void
strlenCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_STRING
))
return
;
checkType
(
c
,
o
,
REDIS_STRING
))
return
;
...
...
src/t_zset.c
View file @
554bd0e7
...
@@ -1196,7 +1196,7 @@ int zsetScore(robj *zobj, robj *member, double *score) {
...
@@ -1196,7 +1196,7 @@ int zsetScore(robj *zobj, robj *member, double *score) {
#define ZADD_NX (1<<1)
/* Don't touch elements not already existing. */
#define ZADD_NX (1<<1)
/* Don't touch elements not already existing. */
#define ZADD_XX (1<<2)
/* Only touch elements already exisitng. */
#define ZADD_XX (1<<2)
/* Only touch elements already exisitng. */
#define ZADD_CH (1<<3)
/* Return num of elements added or updated. */
#define ZADD_CH (1<<3)
/* Return num of elements added or updated. */
void
zaddGenericCommand
(
redisC
lient
*
c
,
int
flags
)
{
void
zaddGenericCommand
(
c
lient
*
c
,
int
flags
)
{
static
char
*
nanerr
=
"resulting score is not a number (NaN)"
;
static
char
*
nanerr
=
"resulting score is not a number (NaN)"
;
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
ele
;
robj
*
ele
;
...
@@ -1388,15 +1388,15 @@ cleanup:
...
@@ -1388,15 +1388,15 @@ cleanup:
}
}
}
}
void
zaddCommand
(
redisC
lient
*
c
)
{
void
zaddCommand
(
c
lient
*
c
)
{
zaddGenericCommand
(
c
,
ZADD_NONE
);
zaddGenericCommand
(
c
,
ZADD_NONE
);
}
}
void
zincrbyCommand
(
redisC
lient
*
c
)
{
void
zincrbyCommand
(
c
lient
*
c
)
{
zaddGenericCommand
(
c
,
ZADD_INCR
);
zaddGenericCommand
(
c
,
ZADD_INCR
);
}
}
void
zremCommand
(
redisC
lient
*
c
)
{
void
zremCommand
(
c
lient
*
c
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
int
deleted
=
0
,
keyremoved
=
0
,
j
;
int
deleted
=
0
,
keyremoved
=
0
,
j
;
...
@@ -1460,7 +1460,7 @@ void zremCommand(redisClient *c) {
...
@@ -1460,7 +1460,7 @@ void zremCommand(redisClient *c) {
#define ZRANGE_RANK 0
#define ZRANGE_RANK 0
#define ZRANGE_SCORE 1
#define ZRANGE_SCORE 1
#define ZRANGE_LEX 2
#define ZRANGE_LEX 2
void
zremrangeGenericCommand
(
redisC
lient
*
c
,
int
rangetype
)
{
void
zremrangeGenericCommand
(
c
lient
*
c
,
int
rangetype
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
int
keyremoved
=
0
;
int
keyremoved
=
0
;
...
@@ -1560,15 +1560,15 @@ cleanup:
...
@@ -1560,15 +1560,15 @@ cleanup:
if
(
rangetype
==
ZRANGE_LEX
)
zslFreeLexRange
(
&
lexrange
);
if
(
rangetype
==
ZRANGE_LEX
)
zslFreeLexRange
(
&
lexrange
);
}
}
void
zremrangebyrankCommand
(
redisC
lient
*
c
)
{
void
zremrangebyrankCommand
(
c
lient
*
c
)
{
zremrangeGenericCommand
(
c
,
ZRANGE_RANK
);
zremrangeGenericCommand
(
c
,
ZRANGE_RANK
);
}
}
void
zremrangebyscoreCommand
(
redisC
lient
*
c
)
{
void
zremrangebyscoreCommand
(
c
lient
*
c
)
{
zremrangeGenericCommand
(
c
,
ZRANGE_SCORE
);
zremrangeGenericCommand
(
c
,
ZRANGE_SCORE
);
}
}
void
zremrangebylexCommand
(
redisC
lient
*
c
)
{
void
zremrangebylexCommand
(
c
lient
*
c
)
{
zremrangeGenericCommand
(
c
,
ZRANGE_LEX
);
zremrangeGenericCommand
(
c
,
ZRANGE_LEX
);
}
}
...
@@ -1922,7 +1922,7 @@ inline static void zunionInterAggregate(double *target, double val, int aggregat
...
@@ -1922,7 +1922,7 @@ inline static void zunionInterAggregate(double *target, double val, int aggregat
}
}
}
}
void
zunionInterGenericCommand
(
redisC
lient
*
c
,
robj
*
dstkey
,
int
op
)
{
void
zunionInterGenericCommand
(
c
lient
*
c
,
robj
*
dstkey
,
int
op
)
{
int
i
,
j
;
int
i
,
j
;
long
setnum
;
long
setnum
;
int
aggregate
=
REDIS_AGGR_SUM
;
int
aggregate
=
REDIS_AGGR_SUM
;
...
@@ -2163,15 +2163,15 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
...
@@ -2163,15 +2163,15 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
zfree
(
src
);
zfree
(
src
);
}
}
void
zunionstoreCommand
(
redisC
lient
*
c
)
{
void
zunionstoreCommand
(
c
lient
*
c
)
{
zunionInterGenericCommand
(
c
,
c
->
argv
[
1
],
REDIS_OP_UNION
);
zunionInterGenericCommand
(
c
,
c
->
argv
[
1
],
REDIS_OP_UNION
);
}
}
void
zinterstoreCommand
(
redisC
lient
*
c
)
{
void
zinterstoreCommand
(
c
lient
*
c
)
{
zunionInterGenericCommand
(
c
,
c
->
argv
[
1
],
REDIS_OP_INTER
);
zunionInterGenericCommand
(
c
,
c
->
argv
[
1
],
REDIS_OP_INTER
);
}
}
void
zrangeGenericCommand
(
redisC
lient
*
c
,
int
reverse
)
{
void
zrangeGenericCommand
(
c
lient
*
c
,
int
reverse
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
int
withscores
=
0
;
int
withscores
=
0
;
...
@@ -2273,16 +2273,16 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
...
@@ -2273,16 +2273,16 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
}
}
}
}
void
zrangeCommand
(
redisC
lient
*
c
)
{
void
zrangeCommand
(
c
lient
*
c
)
{
zrangeGenericCommand
(
c
,
0
);
zrangeGenericCommand
(
c
,
0
);
}
}
void
zrevrangeCommand
(
redisC
lient
*
c
)
{
void
zrevrangeCommand
(
c
lient
*
c
)
{
zrangeGenericCommand
(
c
,
1
);
zrangeGenericCommand
(
c
,
1
);
}
}
/* This command implements ZRANGEBYSCORE, ZREVRANGEBYSCORE. */
/* This command implements ZRANGEBYSCORE, ZREVRANGEBYSCORE. */
void
genericZrangebyscoreCommand
(
redisC
lient
*
c
,
int
reverse
)
{
void
genericZrangebyscoreCommand
(
c
lient
*
c
,
int
reverse
)
{
zrangespec
range
;
zrangespec
range
;
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
...
@@ -2468,15 +2468,15 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
...
@@ -2468,15 +2468,15 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
setDeferredMultiBulkLength
(
c
,
replylen
,
rangelen
);
setDeferredMultiBulkLength
(
c
,
replylen
,
rangelen
);
}
}
void
zrangebyscoreCommand
(
redisC
lient
*
c
)
{
void
zrangebyscoreCommand
(
c
lient
*
c
)
{
genericZrangebyscoreCommand
(
c
,
0
);
genericZrangebyscoreCommand
(
c
,
0
);
}
}
void
zrevrangebyscoreCommand
(
redisC
lient
*
c
)
{
void
zrevrangebyscoreCommand
(
c
lient
*
c
)
{
genericZrangebyscoreCommand
(
c
,
1
);
genericZrangebyscoreCommand
(
c
,
1
);
}
}
void
zcountCommand
(
redisC
lient
*
c
)
{
void
zcountCommand
(
c
lient
*
c
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
zrangespec
range
;
zrangespec
range
;
...
@@ -2553,7 +2553,7 @@ void zcountCommand(redisClient *c) {
...
@@ -2553,7 +2553,7 @@ void zcountCommand(redisClient *c) {
addReplyLongLong
(
c
,
count
);
addReplyLongLong
(
c
,
count
);
}
}
void
zlexcountCommand
(
redisC
lient
*
c
)
{
void
zlexcountCommand
(
c
lient
*
c
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
zlexrangespec
range
;
zlexrangespec
range
;
...
@@ -2633,7 +2633,7 @@ void zlexcountCommand(redisClient *c) {
...
@@ -2633,7 +2633,7 @@ void zlexcountCommand(redisClient *c) {
}
}
/* This command implements ZRANGEBYLEX, ZREVRANGEBYLEX. */
/* This command implements ZRANGEBYLEX, ZREVRANGEBYLEX. */
void
genericZrangebylexCommand
(
redisC
lient
*
c
,
int
reverse
)
{
void
genericZrangebylexCommand
(
c
lient
*
c
,
int
reverse
)
{
zlexrangespec
range
;
zlexrangespec
range
;
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
...
@@ -2809,15 +2809,15 @@ void genericZrangebylexCommand(redisClient *c, int reverse) {
...
@@ -2809,15 +2809,15 @@ void genericZrangebylexCommand(redisClient *c, int reverse) {
setDeferredMultiBulkLength
(
c
,
replylen
,
rangelen
);
setDeferredMultiBulkLength
(
c
,
replylen
,
rangelen
);
}
}
void
zrangebylexCommand
(
redisC
lient
*
c
)
{
void
zrangebylexCommand
(
c
lient
*
c
)
{
genericZrangebylexCommand
(
c
,
0
);
genericZrangebylexCommand
(
c
,
0
);
}
}
void
zrevrangebylexCommand
(
redisC
lient
*
c
)
{
void
zrevrangebylexCommand
(
c
lient
*
c
)
{
genericZrangebylexCommand
(
c
,
1
);
genericZrangebylexCommand
(
c
,
1
);
}
}
void
zcardCommand
(
redisC
lient
*
c
)
{
void
zcardCommand
(
c
lient
*
c
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
...
@@ -2827,7 +2827,7 @@ void zcardCommand(redisClient *c) {
...
@@ -2827,7 +2827,7 @@ void zcardCommand(redisClient *c) {
addReplyLongLong
(
c
,
zsetLength
(
zobj
));
addReplyLongLong
(
c
,
zsetLength
(
zobj
));
}
}
void
zscoreCommand
(
redisC
lient
*
c
)
{
void
zscoreCommand
(
c
lient
*
c
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
zobj
;
robj
*
zobj
;
double
score
;
double
score
;
...
@@ -2842,7 +2842,7 @@ void zscoreCommand(redisClient *c) {
...
@@ -2842,7 +2842,7 @@ void zscoreCommand(redisClient *c) {
}
}
}
}
void
zrankGenericCommand
(
redisC
lient
*
c
,
int
reverse
)
{
void
zrankGenericCommand
(
c
lient
*
c
,
int
reverse
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
robj
*
ele
=
c
->
argv
[
2
];
robj
*
ele
=
c
->
argv
[
2
];
robj
*
zobj
;
robj
*
zobj
;
...
@@ -2904,15 +2904,15 @@ void zrankGenericCommand(redisClient *c, int reverse) {
...
@@ -2904,15 +2904,15 @@ void zrankGenericCommand(redisClient *c, int reverse) {
}
}
}
}
void
zrankCommand
(
redisC
lient
*
c
)
{
void
zrankCommand
(
c
lient
*
c
)
{
zrankGenericCommand
(
c
,
0
);
zrankGenericCommand
(
c
,
0
);
}
}
void
zrevrankCommand
(
redisC
lient
*
c
)
{
void
zrevrankCommand
(
c
lient
*
c
)
{
zrankGenericCommand
(
c
,
1
);
zrankGenericCommand
(
c
,
1
);
}
}
void
zscanCommand
(
redisC
lient
*
c
)
{
void
zscanCommand
(
c
lient
*
c
)
{
robj
*
o
;
robj
*
o
;
unsigned
long
cursor
;
unsigned
long
cursor
;
...
...
Prev
1
2
Next
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