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
68705484
Commit
68705484
authored
Apr 15, 2011
by
Pieter Noordhuis
Browse files
Merge branch '2.4' into 2.4-zset
parents
cf7a1386
577b084e
Changes
4
Show whitespace changes
Inline
Side-by-side
src/redis.c
View file @
68705484
...
@@ -85,8 +85,8 @@ struct redisCommand readonlyCommandTable[] = {
...
@@ -85,8 +85,8 @@ struct redisCommand readonlyCommandTable[] = {
{
"incr"
,
incrCommand
,
2
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"incr"
,
incrCommand
,
2
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"decr"
,
decrCommand
,
2
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"decr"
,
decrCommand
,
2
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"mget"
,
mgetCommand
,
-
2
,
0
,
NULL
,
1
,
-
1
,
1
},
{
"mget"
,
mgetCommand
,
-
2
,
0
,
NULL
,
1
,
-
1
,
1
},
{
"rpush"
,
rpushCommand
,
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"rpush"
,
rpushCommand
,
-
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"lpush"
,
lpushCommand
,
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"lpush"
,
lpushCommand
,
-
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"rpushx"
,
rpushxCommand
,
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"rpushx"
,
rpushxCommand
,
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"lpushx"
,
lpushxCommand
,
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"lpushx"
,
lpushxCommand
,
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"linsert"
,
linsertCommand
,
5
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"linsert"
,
linsertCommand
,
5
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
...
...
src/t_list.c
View file @
68705484
...
@@ -259,30 +259,35 @@ void listTypeConvert(robj *subject, int enc) {
...
@@ -259,30 +259,35 @@ void listTypeConvert(robj *subject, int enc) {
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
void
pushGenericCommand
(
redisClient
*
c
,
int
where
)
{
void
pushGenericCommand
(
redisClient
*
c
,
int
where
)
{
int
j
,
addlen
=
0
,
pushed
=
0
;
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]
);
int
may_have_waiting_clients
=
(
lobj
==
NULL
);
if
(
lobj
==
NULL
)
{
if
(
handleClientsWaitingListPush
(
c
,
c
->
argv
[
1
],
c
->
argv
[
2
])
)
{
if
(
lobj
&&
lobj
->
type
!=
REDIS_LIST
)
{
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
wrongtypeerr
);
return
;
return
;
}
}
lobj
=
createZiplistObject
();
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
lobj
);
for
(
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
c
->
argv
[
j
]
=
tryObjectEncoding
(
c
->
argv
[
j
]);
if
(
may_have_waiting_clients
)
{
if
(
handleClientsWaitingListPush
(
c
,
c
->
argv
[
1
],
c
->
argv
[
j
]))
{
addlen
++
;
continue
;
}
else
{
}
else
{
if
(
lobj
->
type
!=
REDIS_LIST
)
{
may_have_waiting_clients
=
0
;
addReply
(
c
,
shared
.
wrongtypeerr
);
return
;
}
}
if
(
handleClientsWaitingListPush
(
c
,
c
->
argv
[
1
],
c
->
argv
[
2
]))
{
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
addReply
(
c
,
shared
.
cone
);
return
;
}
}
if
(
!
lobj
)
{
lobj
=
createZiplistObject
();
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
lobj
);
}
}
listTypePush
(
lobj
,
c
->
argv
[
2
],
where
);
listTypePush
(
lobj
,
c
->
argv
[
j
],
where
);
addReplyLongLong
(
c
,
listTypeLength
(
lobj
));
pushed
++
;
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
}
server
.
dirty
++
;
addReplyLongLong
(
c
,
addlen
+
(
lobj
?
listTypeLength
(
lobj
)
:
0
));
if
(
pushed
)
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
server
.
dirty
+=
pushed
;
}
}
void
lpushCommand
(
redisClient
*
c
)
{
void
lpushCommand
(
redisClient
*
c
)
{
...
...
src/version.h
View file @
68705484
#define REDIS_VERSION "2.
2.4
"
#define REDIS_VERSION "2.
3.1
"
tests/unit/type/list.tcl
View file @
68705484
...
@@ -55,6 +55,13 @@ start_server {
...
@@ -55,6 +55,13 @@ start_server {
assert_equal $largevalue
(
linkedlist
)
[
r lindex mylist2 2
]
assert_equal $largevalue
(
linkedlist
)
[
r lindex mylist2 2
]
}
}
test
{
Variadic RPUSH/LPUSH
}
{
r del mylist
assert_equal 4
[
r lpush mylist a b c d
]
assert_equal 8
[
r rpush mylist 0 1 2 3
]
assert_equal
{
d c b a 0 1 2 3
}
[
r lrange mylist 0 -1
]
}
test
{
DEL a list - ziplist
}
{
test
{
DEL a list - ziplist
}
{
assert_equal 1
[
r del myziplist2
]
assert_equal 1
[
r del myziplist2
]
assert_equal 0
[
r exists myziplist2
]
assert_equal 0
[
r exists myziplist2
]
...
@@ -142,6 +149,15 @@ start_server {
...
@@ -142,6 +149,15 @@ start_server {
}
}
}
}
test
"BLPOP with variadic LPUSH"
{
set rd
[
redis_deferring_client
]
r del blist target
$rd blpop blist 0
assert_equal 2
[
r lpush blist foo bar
]
assert_equal
{
blist foo
}
[
$rd
read
]
assert_equal bar
[
lindex
[
r lrange blist 0 -1
]
0
]
}
test
"BRPOPLPUSH with zero timeout should block indefinitely"
{
test
"BRPOPLPUSH with zero timeout should block indefinitely"
{
set rd
[
redis_deferring_client
]
set rd
[
redis_deferring_client
]
r del blist target
r del blist target
...
...
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