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
4aab50ac
Commit
4aab50ac
authored
Jun 23, 2016
by
rojingeorge
Browse files
Merge remote-tracking branch 'refs/remotes/antirez/unstable' into unstable
parents
646c958b
f60aa4de
Changes
50
Hide whitespace changes
Inline
Side-by-side
src/t_set.c
View file @
4aab50ac
...
...
@@ -219,11 +219,11 @@ int setTypeRandomElement(robj *setobj, sds *sdsele, int64_t *llele) {
return
setobj
->
encoding
;
}
unsigned
long
setTypeSize
(
robj
*
subject
)
{
unsigned
long
setTypeSize
(
const
robj
*
subject
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_HT
)
{
return
dictSize
((
dict
*
)
subject
->
ptr
);
return
dictSize
((
const
dict
*
)
subject
->
ptr
);
}
else
if
(
subject
->
encoding
==
OBJ_ENCODING_INTSET
)
{
return
intsetLen
((
intset
*
)
subject
->
ptr
);
return
intsetLen
((
const
intset
*
)
subject
->
ptr
);
}
else
{
serverPanic
(
"Unknown set encoding"
);
}
...
...
@@ -351,9 +351,6 @@ void smoveCommand(client *c) {
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
notifyKeyspaceEvent
(
NOTIFY_GENERIC
,
"del"
,
c
->
argv
[
1
],
c
->
db
->
id
);
}
signalModifiedKey
(
c
->
db
,
c
->
argv
[
1
]);
signalModifiedKey
(
c
->
db
,
c
->
argv
[
2
]);
server
.
dirty
++
;
/* Create the destination set when it doesn't exist */
if
(
!
dstset
)
{
...
...
@@ -361,6 +358,10 @@ void smoveCommand(client *c) {
dbAdd
(
c
->
db
,
c
->
argv
[
2
],
dstset
);
}
signalModifiedKey
(
c
->
db
,
c
->
argv
[
1
]);
signalModifiedKey
(
c
->
db
,
c
->
argv
[
2
]);
server
.
dirty
++
;
/* An extra key has changed when ele was successfully added to dstset */
if
(
setTypeAdd
(
dstset
,
ele
->
ptr
))
{
server
.
dirty
++
;
...
...
@@ -547,6 +548,8 @@ void spopWithCountCommand(client *c) {
* the alsoPropagate() API. */
decrRefCount
(
propargv
[
0
]);
preventCommandPropagation
(
c
);
signalModifiedKey
(
c
->
db
,
c
->
argv
[
1
]);
server
.
dirty
++
;
}
void
spopCommand
(
client
*
c
)
{
...
...
src/t_string.c
View file @
4aab50ac
...
...
@@ -263,6 +263,10 @@ void getrangeCommand(client *c) {
}
/* Convert negative indexes */
if
(
start
<
0
&&
end
<
0
&&
start
>
end
)
{
addReply
(
c
,
shared
.
emptybulk
);
return
;
}
if
(
start
<
0
)
start
=
strlen
+
start
;
if
(
end
<
0
)
end
=
strlen
+
end
;
if
(
start
<
0
)
start
=
0
;
...
...
src/t_zset.c
View file @
4aab50ac
...
...
@@ -1100,12 +1100,12 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
* Common sorted set API
*----------------------------------------------------------------------------*/
unsigned
int
zsetLength
(
robj
*
zobj
)
{
unsigned
int
zsetLength
(
const
robj
*
zobj
)
{
int
length
=
-
1
;
if
(
zobj
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
length
=
zzlLength
(
zobj
->
ptr
);
}
else
if
(
zobj
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
{
length
=
((
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
length
=
((
const
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
}
else
{
serverPanic
(
"Unknown sorted set encoding"
);
}
...
...
@@ -2327,16 +2327,13 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
serverPanic
(
"Unknown operator"
);
}
if
(
dbDelete
(
c
->
db
,
dstkey
))
{
signalModifiedKey
(
c
->
db
,
dstkey
);
if
(
dbDelete
(
c
->
db
,
dstkey
))
touched
=
1
;
server
.
dirty
++
;
}
if
(
dstzset
->
zsl
->
length
)
{
zsetConvertToZiplistIfNeeded
(
dstobj
,
maxelelen
);
dbAdd
(
c
->
db
,
dstkey
,
dstobj
);
addReplyLongLong
(
c
,
zsetLength
(
dstobj
));
if
(
!
touched
)
signalModifiedKey
(
c
->
db
,
dstkey
);
signalModifiedKey
(
c
->
db
,
dstkey
);
notifyKeyspaceEvent
(
NOTIFY_ZSET
,
(
op
==
SET_OP_UNION
)
?
"zunionstore"
:
"zinterstore"
,
dstkey
,
c
->
db
->
id
);
...
...
@@ -2344,8 +2341,11 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
}
else
{
decrRefCount
(
dstobj
);
addReply
(
c
,
shared
.
czero
);
if
(
touched
)
if
(
touched
)
{
signalModifiedKey
(
c
->
db
,
dstkey
);
notifyKeyspaceEvent
(
NOTIFY_GENERIC
,
"del"
,
dstkey
,
c
->
db
->
id
);
server
.
dirty
++
;
}
}
zfree
(
src
);
}
...
...
tests/test_helper.tcl
View file @
4aab50ac
...
...
@@ -46,10 +46,12 @@ set ::all_tests {
unit/scripting
unit/maxmemory
unit/introspection
unit/introspection-2
unit/limits
unit/obuf-limits
unit/bitops
unit/bitfield
unit/geo
unit/memefficiency
unit/hyperloglog
unit/lazyfree
...
...
tests/unit/bitfield.tcl
View file @
4aab50ac
...
...
@@ -184,4 +184,9 @@ start_server {tags {"bitops"}} {
}
}
}
test
{
BITFIELD regression for #3221
}
{
r set bits 1
r bitfield bits get u1 0
}
{
0
}
}
tests/unit/bitops.tcl
View file @
4aab50ac
...
...
@@ -43,6 +43,16 @@ start_server {tags {"bitops"}} {
r bitcount no-key
}
0
test
{
BITCOUNT returns 0 with out of range indexes
}
{
r set str
"xxxx"
r bitcount str 4 10
}
0
test
{
BITCOUNT returns 0 with negative indexes where start > end
}
{
r set str
"xxxx"
r bitcount str -6 -7
}
0
catch
{
unset num
}
foreach vec
[
list
""
"
\xaa
"
"
\x00\x00\xff
"
"foobar"
"123"
]
{
incr num
...
...
tests/unit/introspection-2.tcl
0 → 100644
View file @
4aab50ac
start_server
{
tags
{
"introspection"
}}
{
test
{
TTL and TYPYE do not alter the last access time of a key
}
{
r set foo bar
after 3000
r ttl foo
r type foo
assert
{[
r object idletime foo
]
>= 2
}
}
test
{
TOUCH alters the last access time of a key
}
{
r set foo bar
after 3000
r touch foo
assert
{[
r object idletime foo
]
< 2
}
}
test
{
TOUCH returns the number of existing keys specified
}
{
r flushdb
r set key1 1
r set key2 2
r touch key0 key1 key2 key3
}
2
}
tests/unit/scripting.tcl
View file @
4aab50ac
...
...
@@ -142,7 +142,7 @@ start_server {tags {"scripting"}} {
test
{
EVAL - Scripts can't run certain commands
}
{
set e
{}
catch
{
r eval
{
return redis.pcall
(
'
s
pop','x'
)}
0
}
e
catch
{
r eval
{
return redis.pcall
(
'
bl
pop','x'
,0
)}
0
}
e
set e
}
{
*not allowed*
}
...
...
tests/unit/type/list.tcl
View file @
4aab50ac
...
...
@@ -507,7 +507,9 @@ start_server {
create_list xlist
"
$large
c"
assert_equal 3
[
r rpushx xlist d
]
assert_equal 4
[
r lpushx xlist a
]
assert_equal
"a
$large
c d"
[
r lrange xlist 0 -1
]
assert_equal 6
[
r rpushx xlist 42 x
]
assert_equal 9
[
r lpushx xlist y3 y2 y1
]
assert_equal
"y1 y2 y3 a
$large
c d 42 x"
[
r lrange xlist 0 -1
]
}
test
"LINSERT -
$type
"
{
...
...
utils/install_server.sh
View file @
4aab50ac
...
...
@@ -25,9 +25,25 @@
#
################################################################################
#
# Interactive service installer for redis server
# this generates a redis config file and an /etc/init.d script, and installs them
# this scripts should be run as root
# Service installer for redis server, runs interactively by default.
#
# To run this script non-interactively (for automation/provisioning purposes),
# feed the variables into the script. Any missing variables will be prompted!
# Tip: Environment variables also support command substitution (see REDIS_EXECUTABLE)
#
# Example:
#
# sudo REDIS_PORT=1234 \
# REDIS_CONFIG_FILE=/etc/redis/1234.conf \
# REDIS_LOG_FILE=/var/log/redis_1234.log \
# REDIS_DATA_DIR=/var/lib/redis/1234 \
# REDIS_EXECUTABLE=`command -v redis-server` ./utils/install_server.sh
#
# This generates a redis config file and an /etc/init.d script, and installs them.
#
# /!\ This script should be run as root
#
################################################################################
die
()
{
echo
"ERROR:
$1
. Aborting!"
...
...
@@ -42,6 +58,7 @@ SCRIPTPATH=$(dirname $SCRIPT)
#Initial defaults
_REDIS_PORT
=
6379
_MANUAL_EXECUTION
=
false
echo
"Welcome to the redis service installer"
echo
"This script will help you easily set up a running redis server"
...
...
@@ -53,47 +70,61 @@ if [ "$(id -u)" -ne 0 ] ; then
exit
1
fi
#Read the redis port
read
-p
"Please select the redis port for this instance: [
$_REDIS_PORT
] "
REDIS_PORT
if
!
echo
$REDIS_PORT
| egrep
-q
'^[0-9]+$'
;
then
echo
"Selecting default:
$_REDIS_PORT
"
REDIS_PORT
=
$_REDIS_PORT
_MANUAL_EXECUTION
=
true
#Read the redis port
read
-p
"Please select the redis port for this instance: [
$_REDIS_PORT
] "
REDIS_PORT
if
!
echo
$REDIS_PORT
| egrep
-q
'^[0-9]+$'
;
then
echo
"Selecting default:
$_REDIS_PORT
"
REDIS_PORT
=
$_REDIS_PORT
fi
fi
#read the redis config file
_REDIS_CONFIG_FILE
=
"/etc/redis/
$REDIS_PORT
.conf"
read
-p
"Please select the redis config file name [
$_REDIS_CONFIG_FILE
] "
REDIS_CONFIG_FILE
if
[
-z
"
$REDIS_CONFIG_FILE
"
]
;
then
REDIS_CONFIG_FILE
=
$_REDIS_CONFIG_FILE
echo
"Selected default -
$REDIS_CONFIG_FILE
"
_MANUAL_EXECUTION
=
true
#read the redis config file
_REDIS_CONFIG_FILE
=
"/etc/redis/
$REDIS_PORT
.conf"
read
-p
"Please select the redis config file name [
$_REDIS_CONFIG_FILE
] "
REDIS_CONFIG_FILE
if
[
-z
"
$REDIS_CONFIG_FILE
"
]
;
then
REDIS_CONFIG_FILE
=
$_REDIS_CONFIG_FILE
echo
"Selected default -
$REDIS_CONFIG_FILE
"
fi
fi
#read the redis log file path
_REDIS_LOG_FILE
=
"/var/log/redis_
$REDIS_PORT
.log"
read
-p
"Please select the redis log file name [
$_REDIS_LOG_FILE
] "
REDIS_LOG_FILE
if
[
-z
"
$REDIS_LOG_FILE
"
]
;
then
REDIS_LOG_FILE
=
$_REDIS_LOG_FILE
echo
"Selected default -
$REDIS_LOG_FILE
"
_MANUAL_EXECUTION
=
true
#read the redis log file path
_REDIS_LOG_FILE
=
"/var/log/redis_
$REDIS_PORT
.log"
read
-p
"Please select the redis log file name [
$_REDIS_LOG_FILE
] "
REDIS_LOG_FILE
if
[
-z
"
$REDIS_LOG_FILE
"
]
;
then
REDIS_LOG_FILE
=
$_REDIS_LOG_FILE
echo
"Selected default -
$REDIS_LOG_FILE
"
fi
fi
#get the redis data directory
_REDIS_DATA_DIR
=
"/var/lib/redis/
$REDIS_PORT
"
read
-p
"Please select the data directory for this instance [
$_REDIS_DATA_DIR
] "
REDIS_DATA_DIR
if
[
-z
"
$REDIS_DATA_DIR
"
]
;
then
REDIS_DATA_DIR
=
$_REDIS_DATA_DIR
echo
"Selected default -
$REDIS_DATA_DIR
"
_MANUAL_EXECUTION
=
true
#get the redis data directory
_REDIS_DATA_DIR
=
"/var/lib/redis/
$REDIS_PORT
"
read
-p
"Please select the data directory for this instance [
$_REDIS_DATA_DIR
] "
REDIS_DATA_DIR
if
[
-z
"
$REDIS_DATA_DIR
"
]
;
then
REDIS_DATA_DIR
=
$_REDIS_DATA_DIR
echo
"Selected default -
$REDIS_DATA_DIR
"
fi
fi
#get the redis executable path
_REDIS_EXECUTABLE
=
`
command
-v
redis-server
`
read
-p
"Please select the redis executable path [
$_REDIS_EXECUTABLE
] "
REDIS_EXECUTABLE
if
[
!
-x
"
$REDIS_EXECUTABLE
"
]
;
then
REDIS_EXECUTABLE
=
$_REDIS_EXECUTABLE
_MANUAL_EXECUTION
=
true
#get the redis executable path
_REDIS_EXECUTABLE
=
`
command
-v
redis-server
`
read
-p
"Please select the redis executable path [
$_REDIS_EXECUTABLE
] "
REDIS_EXECUTABLE
if
[
!
-x
"
$REDIS_EXECUTABLE
"
]
;
then
echo
"Mmmmm... it seems like you don't have a redis executable. Did you run make install yet?"
exit
1
REDIS_EXECUTABLE
=
$_REDIS_EXECUTABLE
if
[
!
-x
"
$REDIS_EXECUTABLE
"
]
;
then
echo
"Mmmmm... it seems like you don't have a redis executable. Did you run make install yet?"
exit
1
fi
fi
fi
...
...
@@ -112,7 +143,9 @@ echo "Data dir : $REDIS_DATA_DIR"
echo
"Executable :
$REDIS_EXECUTABLE
"
echo
"Cli Executable :
$CLI_EXEC
"
read
-p
"Is this ok? Then press ENTER to go on or Ctrl-C to abort."
_UNUSED_
if
$_MANUAL_EXECUTION
==
true
;
then
read
-p
"Is this ok? Then press ENTER to go on or Ctrl-C to abort."
_UNUSED_
fi
mkdir
-p
`
dirname
"
$REDIS_CONFIG_FILE
"
`
||
die
"Could not create redis config directory"
mkdir
-p
`
dirname
"
$REDIS_LOG_FILE
"
`
||
die
"Could not create redis log dir"
...
...
Prev
1
2
3
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