Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
5afce9b6
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5afce9b6
编写于
6月 13, 2011
作者:
P
Pieter Noordhuis
提交者:
antirez
6月 14, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SETNX regression tests.
上级
0df2e5b9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
11 deletion
+38
-11
tests/unit/basic.tcl
tests/unit/basic.tcl
+38
-11
未找到文件。
tests/unit/basic.tcl
浏览文件 @
5afce9b6
...
...
@@ -138,21 +138,48 @@ start_server {tags {"basic"}} {
r decrby novar 17179869185
}
{
-1
}
test
{
SETNX target key missing
}
{
r setnx novar2 foobared
r get novar2
}
{
foobared
}
test
"SETNX target key missing"
{
r del novar
assert_equal 1
[
r setnx novar foobared
]
assert_equal
"foobared"
[
r get novar
]
}
test
{
SETNX target key exists
}
{
r setnx novar2 blabla
r get novar2
}
{
foobared
}
test
"SETNX target key exists"
{
r set novar foobared
assert_equal 0
[
r setnx novar blabla
]
assert_equal
"foobared"
[
r get novar
]
}
test
{
SETNX against volatile key
}
{
test
"SETNX against not-expired volatile key"
{
r set x 10
r expire x 10000
list
[
r setnx x 20
]
[
r get x
]
}
{
0 10
}
assert_equal 0
[
r setnx x 20
]
assert_equal 10
[
r get x
]
}
test
"SETNX against expired volatile key"
{
# Make it very unlikely for the key this test uses to be expired by the
# active expiry cycle. This is tightly coupled to the implementation of
# active expiry and dbAdd
()
but currently the only way to test that
# SETNX expires a key when it should have been.
for
{
set x 0
}
{
$x
< 9999
}
{
incr x
}
{
r setex key-$x 3600 value
}
# This will be one of 10000 expiring keys. A cycle is executed every
# 100ms, sampling 10 keys for being expired or not. This key will be
# expired for at most 1s when we wait 2s, resulting in a total sample
# of 100 keys. The probability of the success of this test being a
# false positive is therefore approx. 1%.
r set x 10
r expire x 1
# Wait for the key to expire
after 2000
assert_equal 1
[
r setnx x 20
]
assert_equal 20
[
r get x
]
}
test
{
EXISTS
}
{
set res
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录