Redis关于list类型操作
Redis关于list类型操作 1gt;栈的特性:先进后出,后进先出2gt;队列的特性:先进先出,后进后出List是一个链表结构,既可可以做为栈
首页 → 数据库技术
背景:
阅读新闻
Redis关于list类型操作
[日期:2013-11-15] 来源:Linux社区 作者:xiaohongyangok [字体:]
Redis关于list类型操作
1>栈的特性:先进后出,后进先出
2>队列的特性:先进先出,后进后出
List是一个链表结构,既可可以做为栈也可以作为队列处理数据.
lpush mylist "world" //向mylist尾部中放入world
lpush mylist "hello" //向mylist尾部中存入hello
lrange 0 -1 //获取mylist中的所有元素
rpush mylist2 "hello" //向mylist头部中存入hello
rpush mylist2 "world" //向mylist头部中存入world
lrange 0 -1
linsert mylist2 before world "xhy" //向mylist中world元素前插入"xhy"
lset mylist2 0 "example" //设置mylist中的第0个元素的值为"example"
lpush mylist_rem "one"
lpush mylist_rem "one"
lpush mylist_rem "one"
lrem mylist_rem 1 "one //删除1个值为"one"的元素
lpush mylist_ltrim "one"
lpush mylist_ltrim "two"
lpush mylist_ltrim "three"
lpush mylist_ltrim "four"
lpush mylist_ltrim "five"
ltrim mylist_ltrim 2 3 //除了第2和第3个元素,删除其它元素
lpush list_pop 1
lpush list_pop 1
lpush list_pop 1
lrange list_pop 0 -1
lpop list_pop //从头部删除list_pop的第一个元素
rpop list_pop //从尾部删除list_pop的第一个元素
lpush list_1 0
lpush list_1 1
lpush list_1 2
lpush list_1 3
lrange list_1 0 -1
lpush list_2 4
lpush list_2 5
lpush list_2 6
lpush list_2 7
lrange list_2 0 -1
rpoplpush list_1 list_2 //从list_1中的尾部弹出第1个元素并添加到list_2的头部中
lindex list_2 0 //取出list_2第0个元素
lindex list_2 1
llen //返回链表的长度
推荐阅读:
Redis集群明细文档
Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis
Redis系列-安装部署维护篇
CentOS 6.3安装Redis
Redis配置文件redis.conf 详解
Redis 的详细介绍:请点这里
Redis 的下载地址:请点这里
Redis关于string类型和hash类型数据操作
使用Hibernate框架操作MySQL数据库插入中文字符乱码解决
相关资讯 Redis Redis操作 Redis list操作
图片资讯
本文评论 查看全部评论 (0)
评论声明
最新资讯
本周热门
Linux公社简介 - 广告服务 - 网站地图 - 帮助信息 - 联系我们
本站(LinuxIDC)所刊载文章不代表同意其说法或描述,,仅为提供更多信息,也不构成任何建议。
Copyright © 2006-2014 Linux公社 All rights reserved 浙ICP备06018118号

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ČtookazaLovnetakProsto, Kakaožidal.Posenesko

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Redis plays a key role in data storage and management, and has become the core of modern applications through its multiple data structures and persistence mechanisms. 1) Redis supports data structures such as strings, lists, collections, ordered collections and hash tables, and is suitable for cache and complex business logic. 2) Through two persistence methods, RDB and AOF, Redis ensures reliable storage and rapid recovery of data.

In SpringBoot, use Redis to cache OAuth2Authorization object. In SpringBoot application, use SpringSecurityOAuth2AuthorizationServer...

Laravel 8 provides the following options for performance optimization: Cache configuration: Use Redis to cache drivers, cache facades, cache views, and page snippets. Database optimization: establish indexing, use query scope, and use Eloquent relationships. JavaScript and CSS optimization: Use version control, merge and shrink assets, use CDN. Code optimization: Use Composer installation package, use Laravel helper functions, and follow PSR standards. Monitoring and analysis: Use Laravel Scout, use Telescope, monitor application metrics.

Summary Description: Distributed locking is a key tool for ensuring data consistency when developing high concurrency applications. This article will start from a practical case and introduce in detail how to use Composer to install and use the dino-ma/distributed-lock library to solve the distributed lock problem and ensure the security and efficiency of the system.

When developing PHP projects, we often encounter requirements such as frequent operation of databases, management of transactions, and dependency injection. If written manually, these operations are not only time-consuming and labor-intensive, but also prone to errors. Recently, I have encountered similar troubles in my projects, and handling these operations has become extremely complex and difficult to maintain. Fortunately, I found a Composer library called pxniu/study, which greatly simplified my development process. Composer can be learned through the following address: Learning address

The browser's unresponsive method after the WebSocket server returns 401. When using Netty to develop a WebSocket server, you often encounter the need to verify the token. �...
