APPEND key value

Available since 2.0.0, Time complexity: O(1).

Append a value to a key

127.0.0.1:6379> SET foo hello
OK
127.0.0.1:6379> APPEND foo world
(integer) 10
127.0.0.1:6379> GET foo
"helloworld"
127.0.0.1:6379> APPEND bar hello
(integer) 5
127.0.0.1:6379> GET bar
"hello"

More: http://redis.io/commands/appendhttp://www.redis.cn/commands/append.html

BITCOUNT key [start end]

Count set bits in a string

127.0.0.1:6379> SET foo hello
OK
127.0.0.1:6379> BITCOUNT foo
(integer) 21

More: http://redis.io/commands/bitcounthttp://www.redis.cn/commands/bitcount.html

BITOP operation destkey key [key ...]

Perform bitwise operations between strings

127.0.0.1:6379> SET key1 aba
OK
127.0.0.1:6379> SET key2 abb
OK
127.0.0.1:6379> BITOP OR dest key1 key2
(integer) 3
127.0.0.1:6379> GET dest
"abc"

More: http://redis.io/commands/bitophttp://www.redis.cn/commands/bitop.html

BITPOS key bit [start] [end]

Find first bit set or clear in a string

127.0.0.1:6379> SET foo "\xff\xf0\x00"
OK
127.0.0.1:6379> BITPOS foo 0
(integer) 12
127.0.0.1:6379> SET foo "\x00\xff\xf0"
OK
127.0.0.1:6379> BITPOS foo 1
(integer) 8

More: http://redis.io/commands/bitpos

DECR key

Decrement the integer value of a key by one

127.0.0.1:6379> SET foo 10
OK
127.0.0.1:6379> DECR foo
(integer) 9
127.0.0.1:6379> DECR foo
(integer) 8
127.0.0.1:6379> DECR bar
(integer) -1

More: http://redis.io/commands/decrhttp://www.redis.cn/commands/decr.html

DECRBY key decrement

Decrement the integer value of a key by the given number

127.0.0.1:6379> SET foo 10
OK
127.0.0.1:6379> DECRBY foo 3
(integer) 7
127.0.0.1:6379> DECRBY foo 4
(integer) 3

More: http://redis.io/commands/decrbyhttp://www.redis.cn/commands/decrby.html

GET key

Get the value of a key

127.0.0.1:6379> GET foo
(nil)
127.0.0.1:6379> SET foo hello
OK
127.0.0.1:6379> GET foo
"hello"

More: http://redis.io/commands/gethttp://www.redis.cn/commands/get.html

GETBIT key offset

Returns the bit value at offset in the string value stored at key

# binary of code a's ASCII is 01100001
127.0.0.1:6379> SET foo a
OK
127.0.0.1:6379> GETBIT foo 0
(integer) 0
127.0.0.1:6379> GETBIT foo 1
(integer) 1
127.0.0.1:6379> GETBIT foo 2
(integer) 1
127.0.0.1:6379> GETBIT foo 3
(integer) 0
127.0.0.1:6379> GETBIT foo 4
(integer) 0
127.0.0.1:6379> GETBIT foo 5
(integer) 0
127.0.0.1:6379> GETBIT foo 6
(integer) 0
127.0.0.1:6379> GETBIT foo 7
(integer) 1

More: http://redis.io/commands/getbithttp://www.redis.cn/commands/getbit.html

GETRANGE key start end

Get a substring of the string stored at a key

127.0.0.1:6379> SET foo helloworld
OK
127.0.0.1:6379> GETRANGE foo 0 3
"hell"
127.0.0.1:6379> GETRANGE foo 3 5
"low"
127.0.0.1:6379> GETRANGE foo 5 -1
"world"

More: http://redis.io/commands/getrangehttp://www.redis.cn/commands/getrange.html

GETSET key value

Set the string value of a key and return its old value

127.0.0.1:6379> SET foo hello
OK
127.0.0.1:6379> GETSET foo world
"hello"
127.0.0.1:6379> GET foo
"world"

More: http://redis.io/commands/getsethttp://www.redis.cn/commands/getset.html

INCR key

Increment the integer value of a key by one

127.0.0.1:6379> SET foo 10
OK
127.0.0.1:6379> INCR foo
(integer) 11
127.0.0.1:6379> INCR foo
(integer) 12
127.0.0.1:6379> INCR bar
(integer) 1

More: http://redis.io/commands/incrhttp://www.redis.cn/commands/incr.html

INCRBY key increment

Increment the integer value of a key by the given amount

127.0.0.1:6379> SET foo 10
OK
127.0.0.1:6379> INCRBY foo 2
(integer) 12
127.0.0.1:6379> INCRBY foo 3
(integer) 15
127.0.0.1:6379> INCRBY bar 4
(integer) 4

More: http://redis.io/commands/incrbyhttp://www.redis.cn/commands/incrby.html

INCRBYFLOAT key increment

Increment the float value of a key by the given amount

127.0.0.1:6379> SET foo 10
OK
127.0.0.1:6379> INCRBYFLOAT foo 2.3
"12.3"
127.0.0.1:6379> INCRBYFLOAT foo 5.8E2
"592.29999999999999999"
127.0.0.1:6379>
127.0.0.1:6379> INCRBYFLOAT bar 3.33
"3.33"

More: http://redis.io/commands/incrbyfloathttp://www.redis.cn/commands/incrbyfloat.html

MGET key [key ...]

Get the values of all the given keys

127.0.0.1:6379> SET foo hello
OK
127.0.0.1:6379> SET bar world
OK
127.0.0.1:6379> MGET foo bar
1) "hello"
2) "world"

More: http://redis.io/commands/mgethttp://www.redis.cn/commands/mget.html

MSET key value [key value ...]

Set multiple keys to multiple values

127.0.0.1:6379> MSET foo hello bar world
OK
127.0.0.1:6379> MGET foo bar
1) "hello"
2) "world"

More: http://redis.io/commands/msethttp://www.redis.cn/commands/mset.html

MSETNX key value [key value ...]

Set multiple keys to multiple values, only if none of the keys exist

127.0.0.1:6379> SET foo hello
OK
127.0.0.1:6379> MSETNX foo world bar world
(integer) 0
127.0.0.1:6379> MGET foo bar
1) "hello"
2) (nil)

More: http://redis.io/commands/msetnxhttp://www.redis.cn/commands/msetnx.html

PSETEX key milliseconds value

Set the value and expiration in milliseconds of a key

127.0.0.1:6379> PSETEX foo 10000 hello
OK
127.0.0.1:6379> PTTL foo
(integer) 8404
127.0.0.1:6379> GET foo
"hello"
127.0.0.1:6379> PTTL foo
(integer) -2
127.0.0.1:6379> GET foo
(nil)

More: http://redis.io/commands/psetexhttp://www.redis.cn/commands/psetex.html

SET key value [EX seconds] [PX milliseconds] [NX|XX]

Set the string value of a key

127.0.0.1:6379> SET foo hello
OK
127.0.0.1:6379> GET foo
"hello"

More: http://redis.io/commands/sethttp://www.redis.cn/commands/set.html

SETBIT key offset value

Sets or clears the bit at offset in the string value stored at key

127.0.0.1:6379> SET foo a
OK
127.0.0.1:6379> GETBIT foo 7
(integer) 1
127.0.0.1:6379> SETBIT foo 7 0
(integer) 1

More: http://redis.io/commands/setbithttp://www.redis.cn/commands/setbit.html

SETEX key seconds value

Set the value and expiration of a key

127.0.0.1:6379> SETEX foo 10 hello
OK
127.0.0.1:6379> TTL foo
(integer) 8
127.0.0.1:6379> GET foo
"hello"
127.0.0.1:6379> TTL foo
(integer) -2
127.0.0.1:6379> GET foo
(nil)

More: http://redis.io/commands/setexhttp://www.redis.cn/commands/setex.html

SETNX key value

Set the value of a key, only if the key does not exist

127.0.0.1:6379> SETNX foo hello
(integer) 1
127.0.0.1:6379> GET foo
"hello"
127.0.0.1:6379> SETNX foo world
(integer) 0
127.0.0.1:6379> GET foo
"hello"

More: http://redis.io/commands/setnxhttp://www.redis.cn/commands/msetnx.html

SETRANGE key offset value

Overwrite part of a string at key starting at the specified offset

127.0.0.1:6379> SET foo helloworld
OK
127.0.0.1:6379> SETRANGE foo 5 redis
(integer) 10
127.0.0.1:6379> GET foo
"helloredis"

More: http://redis.io/commands/setrangehttp://www.redis.cn/commands/setrange.html

STRLEN key

Get the length of the value stored in a key

127.0.0.1:6379> set foo hello
OK
127.0.0.1:6379> STRLEN foo
(integer) 5

More: http://redis.io/commands/strlenhttp://www.redis.cn/commands/strlen.html

Redis 命令 - Strings的更多相关文章

  1. 常用 redis 命令(for php)

    Redis 主要能存储 5 种数据结构,分别是 strings,hashes,lists,sets 以及 sorted sets. 新建一个 redis 数据库 $redis = new Redis( ...

  2. redis命令大全

    redis windows下使用及redis命令 Redis 是一个开源,高级的键值对的存储.它经常作为服务端的数据结构,它的键的数据类型能够是strings, hashs, lists, sets( ...

  3. Redis数据类型Strings、Lists常用操作指令

    Redis数据类型Strings.Lists常用操作指令 Strings常用操作指令 GET.SET相关操作 # GET 获取键值对 127.0.0.1:6379> get name (nil) ...

  4. Redis命令拾遗二(散列类型)

    本文版权归博客园和作者吴双共同所有,欢迎转载,转载和爬虫请注明原文地址 :博客园蜗牛NoSql系列地址  http://www.cnblogs.com/tdws/tag/NoSql/ Redis命令拾 ...

  5. redis命令总结

     Redis命令总结 redis 127.0.0.1:6379> info  #查看server版本内存使用连接等信息 redis 127.0.0.1:6379> client list  ...

  6. redis如何执行redis命令

    Redis 命令 Redis 命令用于在 redis 服务上执行操作.所以我们必须要启动Redis服务程序,也就是redis安装目录下的redis-server.exe,你可以双击执行,也可以打开cm ...

  7. Redis命令大全&中文解释&在线测试命令工具&在线中文文档

    在线测试命令地址:http://try.redis.io/ 官方文档:http://redis.io/commands http://redis.io/documentation Redis 命令参考 ...

  8. Redis命令

    redis的常用命令主要分为两个方面.一个是键值相关命令.一个是服务器相关命令(redis-cli进入终端) 1.键值相关命令 keys * 取出当前所有的key exists name 查看n是否有 ...

  9. redis命令参考

    http://doc.redisfans.com/ 进入redis命令行模式方式: 1.进入redis安装目录 2.运行redis-cli

随机推荐

  1. C#Windows窗体界面设计_01_绘制三角函数_五点作图法

    binzhouweichao@163.com Visual Stutio 2010 C#开发环境 五点作图绘制三角函数,以正弦函数为例,选取一个周期[0, 2π]上的五个特殊的点,也就是横坐标0, π ...

  2. 从Jetty、Tomcat和Mina中提炼NIO构架网络服务器的经典模式(三)

    转载 http://blog.csdn.net/cutesource/article/details/6192163 最后我们再看看NIO方面最著名的框架Mina,抛开Mina有关session和处理 ...

  3. Ioc容器Autofac系列(3)-- 三种注册组件的方式

    简单来说,所谓注册组件,就是注册类并映射为接口,然后根据接口获取对应类,Autofac将被注册的类称为组件. 虽然可像上篇提到的一次性注册程序集中所有类,但AutoFac使用最多的还是单个注册.这种注 ...

  4. EcShop之路-Smarty

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...

  5. SASS优化响应式断点管理

    前端开发whqet,csdn,王海庆,whqet,前端开发专家 原文:<Managing Responsive Breakpoints with Sass> 作者:Hugo Giraude ...

  6. Python 删除目录中特定文件

    代码如下,使用了递归: import sys currDir = sys.path[] import os def removeFile(dir,postfix): if os.path.isdir( ...

  7. 苹果ipa软件包破解笔记

    苹果的验证机制: Appstore上的应用都採用了DRM(digital rights management)数字版权加密保护技术,直接的表现是A帐号购买的app,除A外的帐号无法使用,事实上就是有了 ...

  8. 【转】Delphi调用webservice总结

    原文:http://www.cnblogs.com/zhangzhifeng/archive/2013/08/15/3259084.html Delphi调用C#写的webservice 用delph ...

  9. Thread+Handler 线程 消息循环(转载)

    近来找了一些关于android线程间通信的资料,整理学习了一下,并制作了一个简单的例子. andriod提供了 Handler 和 Looper 来满足线程间的通信.例如一个子线程从网络上下载了一副图 ...

  10. WWDC2015