Redis 命令 - Lists
BLPOP key [key ...] timeout
Remove and get the first element in a list, or block until one is available
More: http://redis.io/commands/blpop, http://www.redis.cn/commands/blpop.html
BRPOP key [key ...] timeout
Remove and get the last element in a list, or block until one is available
More: http://redis.io/commands/brpop, http://www.redis.cn/commands/brpop.html
BRPOPLPUSH source destination timeout
Pop a value from a list, push it to another list and return it; or block until one is available
More: http://redis.io/commands/brpoplpush, http://www.redis.cn/commands/brpoplpush.html
LINDEX key index
Get an element from a list by its index
127.0.0.1:6379> LPUSH foo 1 3 5 7 9
(integer) 5
127.0.0.1:6379> LINDEX foo 1
"7"
127.0.0.1:6379> LINDEX foo -2
"3"
More: http://redis.io/commands/lindex, http://www.redis.cn/commands/lindex.html
LINSERT key BEFORE|AFTER pivot value
Insert an element before or after another element in a list
127.0.0.1:6379> LPUSH foo 10 20 40 80
(integer) 4
127.0.0.1:6379> LINSERT foo BEFORE 20 80
(integer) 5
127.0.0.1:6379> LRANGE foo 0 -1
1) "80"
2) "40"
3) "80"
4) "20"
5) "10"
127.0.0.1:6379> LINSERT foo AFTER 80 0
(integer) 6
127.0.0.1:6379> LRANGE foo 0 -1
1) "80"
2) "0"
3) "40"
4) "80"
5) "20"
6) "10"
More: http://redis.io/commands/linsert, http://www.redis.cn/commands/linsert.html
LLEN key
Get the length of a list
127.0.0.1:6379> LPUSH foo 1 2 4
(integer) 3
127.0.0.1:6379> LLEN foo
(integer) 3
More: http://redis.io/commands/llen, http://www.redis.cn/commands/llen.html
LPOP key
Remove and get the first element in a list
127.0.0.1:6379> LPUSH foo 1 2 4 8
(integer) 4
127.0.0.1:6379> LPOP foo
"8"
127.0.0.1:6379> LPOP foo
"4"
More: http://redis.io/commands/lpop, http://www.redis.cn/commands/lpop.html
LPUSH key value [value ...]
Prepend one or multiple values to a list
127.0.0.1:6379> LPUSH foo 1
(integer) 1
127.0.0.1:6379> LPUSH foo 2 4
(integer) 3
127.0.0.1:6379> LRANGE foo -1 0
(empty list or set)
127.0.0.1:6379>
127.0.0.1:6379> LRANGE foo 0 -1
1) "4"
2) "2"
3) "1"
More: http://redis.io/commands/lpush, http://www.redis.cn/commands/lpush.html
LPUSHX key value
Prepend a value to a list, only if the list exists
127.0.0.1:6379> LPUSHX foo 1
(integer) 0
127.0.0.1:6379> LRANGE foo 0 -1
(empty list or set)
127.0.0.1:6379> LPUSH foo 1
(integer) 1
127.0.0.1:6379> LPUSHX foo 2
(integer) 2
127.0.0.1:6379> LRANGE foo 0 -1
1) "2"
2) "1"
More: http://redis.io/commands/lpushx, http://www.redis.cn/commands/lpushx.html
LRANGE key start stop
Get a range of elements from a list
127.0.0.1:6379> LPUSH foo 1 3 5 7 9
(integer) 5
127.0.0.1:6379> LRANGE foo 1 3
1) "7"
2) "5"
3) "3"
127.0.0.1:6379> LRANGE foo 0 -1
1) "9"
2) "7"
3) "5"
4) "3"
5) "1"
More: http://redis.io/commands/lrange, http://www.redis.cn/commands/lrange.html
LREM key count value
Remove elements from a list
127.0.0.1:6379> RPUSH foo 1 2 1 3 1 4
(integer) 6
127.0.0.1:6379> LREM foo 2 1
(integer) 2
127.0.0.1:6379> LRANGE foo 0 -1
1) "2"
2) "3"
3) "1"
4) "4"
127.0.0.1:6379> RPUSH foo 3 1 3 2 1 3
(integer) 10
127.0.0.1:6379> LREM foo -3 3
(integer) 3
127.0.0.1:6379> LRANGE foo 0 -1
1) "2"
2) "3"
3) "1"
4) "4"
5) "1"
6) "2"
7) "1"
127.0.0.1:6379> LREM foo 0 1
(integer) 3
127.0.0.1:6379> LRANGE foo 0 -1
1) "2"
2) "3"
3) "4"
4) "2"
More: http://redis.io/commands/lrem, http://www.redis.cn/commands/lrem.html
LSET key index value
Set the value of an element in a list by its index
127.0.0.1:6379> RPUSH foo 1 2 3 4 5
(integer) 5
127.0.0.1:6379> LSET foo 3 0
OK
127.0.0.1:6379> LRANGE foo 0 -1
1) "1"
2) "2"
3) "3"
4) "0"
5) "5"
More: http://redis.io/commands/lset, http://www.redis.cn/commands/lset.html
LTRIM key start stop
Trim a list to the specified range
127.0.0.1:6379> RPUSH foo 1 3 5 7 9
(integer) 5
127.0.0.1:6379> LTRIM foo 3 -1
OK
127.0.0.1:6379> LRANGE foo 0 -1
1) "7"
2) "9"
More: http://redis.io/commands/ltrim, http://www.redis.cn/commands/ltrim.html
RPOP key
Remove and get the last element in a list
127.0.0.1:6379> RPUSH foo 1 2 3 4
(integer) 4
127.0.0.1:6379> RPOP foo
"4"
127.0.0.1:6379> RPOP foo
"3"
127.0.0.1:6379> LRANGE foo 0 -1
1) "1"
2) "2"
More: http://redis.io/commands/rpop, http://www.redis.cn/commands/rpop.html
RPOPLPUSH source destination
Remove the last element in a list, prepend it to another list and return it
127.0.0.1:6379> RPUSH foo 1 3 5
(integer) 3
127.0.0.1:6379> RPUSH bar 2 4
(integer) 2
127.0.0.1:6379> RPOPLPUSH foo bar
"5"
127.0.0.1:6379> LRANGE foo 0 -1
1) "1"
2) "3"
127.0.0.1:6379> LRANGE bar 0 -1
1) "5"
2) "2"
3) "4"
127.0.0.1:6379> RPOPLPUSH bar bar
"4"
127.0.0.1:6379> LRANGE bar 0 -1
1) "4"
2) "5"
3) "2"
More: http://redis.io/commands/rpoplpush, http://www.redis.cn/commands/rpoplpush.html
RPUSH key value [value ...]
Append one or multiple values to a list
127.0.0.1:6379> RPUSH foo 1
(integer) 1
127.0.0.1:6379> RPUSH foo 1 2 3
(integer) 4
127.0.0.1:6379> LRANGE foo 0 -1
1) "1"
2) "1"
3) "2"
4) "3"
More: http://redis.io/commands/rpush, http://www.redis.cn/commands/rpush.html
RPUSHX key value
Append a value to a list, only if the list exists
127.0.0.1:6379> RPUSHX foo 1
(integer) 0
127.0.0.1:6379> LRANGE foo 0 -1
(empty list or set)
127.0.0.1:6379> RPUSH foo 1
(integer) 1
127.0.0.1:6379> RPUSHX foo 2
(integer) 2
127.0.0.1:6379> LRANGE foo 0 -1
1) "1"
2) "2"
More: http://redis.io/commands/rpushx, http://www.redis.cn/commands/rpushx.html
Redis 命令 - Lists的更多相关文章
- 常用 redis 命令(for php)
Redis 主要能存储 5 种数据结构,分别是 strings,hashes,lists,sets 以及 sorted sets. 新建一个 redis 数据库 $redis = new Redis( ...
- redis命令大全
redis windows下使用及redis命令 Redis 是一个开源,高级的键值对的存储.它经常作为服务端的数据结构,它的键的数据类型能够是strings, hashs, lists, sets( ...
- Redis的Lists数据类型
Lists 就是链表,相信略有数据结构知识的人都应该能理解其结构.使用Lists结构,我们可以轻松地实现最新消息排行等功能.Lists的另一个应用就是消息队列,可以利用Lists的PUSH操作,将任务 ...
- redis命令学习(二) · THIS SPACE
列表(Lists)操作命令 Redis列表是简单的字符串列表,按照插入顺序排序. 你可以添加一个元素导列表的头部(左边)或者尾部(右边)LPUSH命令插入一个新的元素导头部,而RPUSH插入一个新元素 ...
- Redis命令拾遗二(散列类型)
本文版权归博客园和作者吴双共同所有,欢迎转载,转载和爬虫请注明原文地址 :博客园蜗牛NoSql系列地址 http://www.cnblogs.com/tdws/tag/NoSql/ Redis命令拾 ...
- redis命令总结
Redis命令总结 redis 127.0.0.1:6379> info #查看server版本内存使用连接等信息 redis 127.0.0.1:6379> client list ...
- redis如何执行redis命令
Redis 命令 Redis 命令用于在 redis 服务上执行操作.所以我们必须要启动Redis服务程序,也就是redis安装目录下的redis-server.exe,你可以双击执行,也可以打开cm ...
- Redis命令大全&中文解释&在线测试命令工具&在线中文文档
在线测试命令地址:http://try.redis.io/ 官方文档:http://redis.io/commands http://redis.io/documentation Redis 命令参考 ...
- Redis命令
redis的常用命令主要分为两个方面.一个是键值相关命令.一个是服务器相关命令(redis-cli进入终端) 1.键值相关命令 keys * 取出当前所有的key exists name 查看n是否有 ...
随机推荐
- iOS-图片png
把图片添加到工程里面:就报了108个警告!!! 然后我发现我添加的图片有很多命名是这样子的: xcode去找图片的时候是按照什么方式找的呢????? 还发现有好几张同名的图片..... ------- ...
- Weblogic安装
1.下载wls_121200.jar, 2.输入cnd打开命令提示 3.f:进入F盘 4.Java -version 验证是否配置Java环境, 5.echo %path% 查看环境变量 6.set ...
- java中的定时器
所有类型的 Java 应用程序一般都需要计划重复执行的任务.企业应用程序需要计划每日的日志或者晚间批处理过程.一个 J2SE或者 J2ME 日历应用程序需要根据用户的约定计划闹铃时间.不过,标准的调度 ...
- iOS开发-为程序添加应用设置
一.设置捆绑包 设置捆绑包是应用自带的一组文件,用于告诉设置该应用期望得到用户的哪些偏好设置. 新建设置捆绑包:Command+N,在iOS部分中的Resource,选择Settings Bundle ...
- 使用jdk操作 wsdl2java (wedservice)
打开jdk下的bin目录 看下能否找到"wsimport.exe"这个文件 一般情况下都会有 如果没有则说明你的JDK不支持这个功能 然后在DOS窗口下输入wsimport 敲回车 ...
- MEF 编程指南(七):使用目录
目录(Catalogs) MEF 特性编程模型的核心价值,拥有通过目录动态地发现部件的能力.目录允许应用程序轻松地使用那些通过 Export Attribute 注册自身的导出.下面列出 MEF ...
- uva 10152 ShellSort
//这个算法用到了"相对位置"的思想,并且就本题而言还有一个很重要的结论就是,假设 //移动了k个元素,那么这k个元素一定是最后结果的那个序列的前k个元素,而且易知, //越先移动 ...
- PostgreSQL的 initdb 源代码分析之二十四
继续分析: make_template0(); 展开: 无需再作解释,就是创建template0数据库 /* * copy template1 to template0 */ static void ...
- 学习JSONP
最近自己研究 跨域调用js,然后 发现 有jsonp 这种技术,在Jquery中可以使用,于是 研究下原理 发现: 其实 就是 利用<script>的跨域访问的能力. 调用 服务端 返回的 ...
- JQuery UI Widget Factory官方Demo
<!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...