Redis:命令:修订间差异
无编辑摘要 |
|||
第17行: | 第17行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===数字操作=== | |||
可通过 <span class="article-label">INCR</span>, <span class="article-label">INCRBY</span>, <span class="article-label">DECR</span> and <span class="article-label">DECRBY</span>等操作数字: | |||
<syntaxhighlight lang="bash"> | |||
> set counter 100 | |||
OK | |||
> incr counter | |||
(integer) 101 | |||
> incr counter | |||
(integer) 102 | |||
> incrby counter 50 | |||
(integer) 152 | |||
</syntaxhighlight> | |||
===批量设置=== | |||
<syntaxhighlight lang="bash"> | |||
> mset a 10 b 20 c 30 | |||
OK | |||
> mget a b c | |||
1) "10" | |||
2) "20" | |||
3) "30" | |||
</syntaxhighlight> | |||
[[Category:Database]] | [[Category:Database]] |
2021年5月6日 (四) 01:52的版本
基本操作
增删改查
设置key的value
> set mykey somevalue
OK
> get mykey
"somevalue"
设置的时候支持附加条件,仅在value不存在(或者存在)的时候才设置值
> set mykey newval nx
(nil)
> set mykey newval xx
OK
数字操作
可通过 INCR, INCRBY, DECR and DECRBY等操作数字:
> set counter 100
OK
> incr counter
(integer) 101
> incr counter
(integer) 102
> incrby counter 50
(integer) 152
批量设置
> mset a 10 b 20 c 30
OK
> mget a b c
1) "10"
2) "20"
3) "30"