LPUSH list_name value [value ...]

Prepend one or multiple values to a list

从左侧插入值,最早插入的值在最右边

LPUSHX list_name value

Prepend a value to a list, only if the list exists

判断列表是否存在,如果存在就插入值,不存在就不插入值,只能插入一次,从左边插入

LINSERT list_name BEFORE|AFTER pivot value

Insert an element before or after another element in a list

r.linsert('list1', 'before', 6, 7)

在列表的某个值前面或者后面插入新的值,因为是从左侧计算,所以前面就是左侧,后面就是右侧

RPUSH list_name value [value ...]

Append one or multiple values to a list

r.rpush('list1', 8, 9)

从列表右侧插入值,可以一次插入多个

RPUSHX list_name value

Append a value to a list, only if the list exists

r.rpushx('list1', 9)

判断列表是否存在,存在的话就从列表的右侧插入值,一次只能插入一个,不存在就不能创建

LPOP list_name

Remove and get the first element in a list

r.lpop('list1')

从列表的最左侧返回元素

RPOP key

Remove and get the last element in a list

r.rpop('list1')

从列表的最右侧返回元素

BLPOP list_name1 [list_name2 ...] timeout

Remove and get the first element in a list, or block until one is available

如果操作的列表不存在就是会阻塞住

r.blpop('list2')

r.blpop(["list1","list2"])

r.blpop(["list1","list2"], 100)

取出队列列表中不空队列的最左侧元素,如果都是为空,那就阻塞

BRPOP list_name1 [list_name2 ...] timeout

Remove and get the last element in a list, or block until one is available

如果操作的列表不存在就是会阻塞住

r.brpop('list2')

r.brpop(["list1","list2"])

r.brpop(["list1","list2"], 100)

取出队列列表中不空队列的最右侧元素,如果都是为空,那就阻塞

LSET list_name index value

Set the value of an element in a list by its index

r.lset('list1', 0, 999)

设置队列指定下标的值

LINDEX list_name index

Get an element from a list by its index

r.lindex('list1', 1)

获取队列中指定下标的值

LRANGE list_name start stop

Get a range of elements from a list

r.lrange('list1', 0, 3)

获取队列中指定范围的值

LLEN list_name

Get the length of a list

r.llen('list1')

获取队列长度

LREM list_name value count

Remove elements from a list

r.lrem('list1', 999, 0)

删除队列中的指定值

name:  redis的list名称

value: 要删除的值

num:   num=0 删除列表中所有的指定值;

num=2 从前到后,删除2个;

num=-2 从后向前,删除2个'''

LTRIM list_name start stop

Trim a list to the specified range

r.ltrim('list1', 0, 1)

移除列表内没有在该索引之内的值

RPOPLPUSH source destination

Remove the last element in a list, prepend it to another list and return it

r.rpoplpush('list1', 'list2')

将源队列中最右侧的数据弹出,并插入目的队列的最左侧,同时作为返回值

BRPOPLPUSH source destination timeout

Pop a value from a list, push it to another list and return it; or block until one is available

将源队列中最右侧的数据弹出,并插入目的队列的最左侧,同时作为返回值,没有值得时候会阻塞

python redis list操作的更多相关文章

  1. Python --Redis Hash操作

    一.Redis Hash操作 Redis 数据库hash数据类型是一个string类型的key和value的映射表,适用于存储对象.Redis 中每个 hash 可以存储 232 - 1 键值对(40 ...

  2. Python Redis常用操作(持续更新)

    目录 1.Redis简介 2.Redis部署 3.Redis API应用 4.String操作 1.Redis简介 redis是业界主流的key-value,nosql数据库之一.和Memcached ...

  3. Python Redis pipeline操作

    Redis是建立在TCP协议基础上的CS架构,客户端client对redis server采取请求响应的方式交互. 一般来说客户端从提交请求到得到服务器相应,需要传送两个tcp报文. 设想这样的一个场 ...

  4. Python Redis pipeline操作和Redis乐观锁保持数据一致性

    Redis是建立在TCP协议基础上的CS架构,客户端client对redis server采取请求响应的方式交互. redis 乐观锁:也可理解为版本号比较机制,主要是说在读取数据逇时候同时读取其版本 ...

  5. Python Redis pipeline操作(秒杀实现)

    设想这样的一个场景,你要批量的执行一系列redis命令,例如执行100次get key,这时你要向redis请求100次+获取响应100次.如果能一次性将100个请求提交给redis server,执 ...

  6. Python Redis 常用操作

    delete(*names) # 根据删除redis中的任意数据类型 exists(name) # 检测redis的name是否存在 keys(pattern='*') # 根据模型获取redis的n ...

  7. python:redis简单操作

    一,安装redis-py pip install redis easy_install redis 二,简单用法 import redis # 连接redis服务器 def conn_redis(): ...

  8. java、python及jmeter操作redis(接口自动化必备)

    redis是nosql数据库之一,其存储结构简单,提供高性能服务,所以在架构中是很常用的. 在做接口自动化测试过程中,有时也会涉及到redis,比如:发送短信验证码,我们做接口自动化测试,如何模拟发送 ...

  9. python连接redis、redis字符串操作、hash操作、列表操作、其他通用操作、管道、django中使用redis

    今日内容概要 python连接redis redis字符串操作 redis之hash操作 redis之列表操作 redis其他 通用操作,管道 django中使用redis 内容详细 1.python ...

随机推荐

  1. ENC28j60以太网芯片驱动程序简介

    ENC28j60以太网芯片驱动程序简介 ENC28J60 驱动开发要点 enc28J60 和 Arduino (1)——ping通你的Arduino MCU51单片机uIP协议栈+ENC28J60网卡 ...

  2. 【bfs】 poj 3984 maze 队列存储

    #include <iostream> #include <stdio.h> #include <cstring> #define Max 0x7f7f7f7f u ...

  3. GCD应用场景

    1.计算文件大小放在子线程中中计算,计算完了,回到主线程更新UI

  4. php cookies自动登录

    <?php header('Content-type: text/html; charset=utf-8'); error_reporting(0); //自动登陆 if($_COOKIE[&q ...

  5. g++ 编译c文件

    //编译c文件为.o文件 g++ -c virify.c //打包.o文件为.a静态库文件 ar crv libandroid_um36_virify.a virify.o //将静态库.a文件编译进 ...

  6. html5 localStorage和sessionStorage

    该随便来自: http://www.cnblogs.com/yuzhongwusan/archive/2011/12/19/2293347.html html5中的Web Storage包括了两种存储 ...

  7. UIImage 和 UIImageView区别

    // // ViewController.m // 06-UIImage 和 UIImageView // // Created by Stephen on 16/4/18. // Copyright ...

  8. Light OJ 1006 - Hex-a-bonacci

    题目链接:http://acm.hust.edu.cn/vjudge/contest/121396#problem/G http://lightoj.com/volume_showproblem.ph ...

  9. PAT (Advanced Level) 1115. Counting Nodes in a BST (30)

    简单题.统计一下即可. #include<cstdio> #include<cstring> #include<cmath> #include<vector& ...

  10. Effective java -- 4 泛型

    第二十三条:请不要在代码中使用原生态类型就是像Set这种待泛型的,就把泛型明确写出来. 第二十四条:消除非受检警告就是Set<String> sets = new HashSet();这种 ...