Redis 数据结构之Keys

这是Redis官方文档的keys列表
(1) set key value--设置某个键为某个值
(2) get key -- 获取设置的值
(3)del key -- 删除设置的键
(4)expire key seconds-- 设置键值的存在时间
(5)expireat key timestamp -- 更高级的键值保存时间。
(6)keys pattern --查看键值的个数 (keys *可以返回所有的键)
(7)move key db -- 将某个键值移动到另外的数据库(可以用select db来选择数据库)
(8)object --
The OBJECT command allows to inspect the internals of Redis Objects associated with keys. It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. Your application may also use the information reported by the OBJECT command to implement application level key eviction policies when using Redis as a Cache.
The OBJECT command supports multiple sub commands:
OBJECT REFCOUNT <key>returns the number of references of the value associated with the specified key. This command is mainly useful for debugging.OBJECT ENCODING <key>returns the kind of internal representation used in order to store the value associated with a key.OBJECT IDLETIME <key>returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations). While the value is returned in seconds the actual resolution of this timer is 10 seconds, but may vary in future implementations.
Objects can be encoded in different ways:
- Strings can be encoded as
raw(normal string encoding) orint(strings representing integers in a 64 bit signed interval are encoded in this way in order to save space). - Lists can be encoded as
ziplistorlinkedlist. Theziplistis the special representation that is used to save space for small lists. - Sets can be encoded as
intsetorhashtable. Theintsetis a special encoding used for small sets composed solely of integers. - Hashes can be encoded as
zipmaporhashtable. Thezipmapis a special encoding used for small hashes. - Sorted Sets can be encoded as
ziplistorskiplistformat. As for the List type small sorted sets can be specially encoded usingziplist, while theskiplistencoding is the one that works with sorted sets of any size.
All the specially encoded types are automatically converted to the general type once you perform an operation that makes it impossible for Redis to retain the space saving encoding.
Return value
Different return values are used for different subcommands.
- Subcommands
refcountandidletimereturn integers. - Subcommand
encodingreturns a bulk reply.
If the object you try to inspect is missing, a null bulk reply is returned.
Examples
redis> lpush mylist "Hello World"
(integer) 4
redis> object refcount mylist
(integer) 1
redis> object encoding mylist
"ziplist"
redis> object idletime mylist
(integer) 10
In the following example you can see how the encoding changes once Redis is no longer able to use the space saving encoding.
redis> set foo 1000
OK
redis> object encoding foo
"int"
redis> append foo bar
(integer) 7
redis> get foo
"1000bar"
redis> object encoding foo
"raw"
(9)pexpire key milliseconds -- 设置毫秒级别的键值保存
(10)pexpireat key milliseconds--timestap
(11)ttl key -- 返回设置的键值保存期限还有多少秒!
(12)rename key newkey -- 重新命名一个新的key值
(13)renamenx key newkey -- 重新命名一个新的key值仅仅在key 不存在的情况下
(14)SORT key [BY pattern] [LIMIT offset count][GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA][STORE destination]
Redis 数据结构之Keys的更多相关文章
- Redis 数据结构与内存管理策略(下)
Redis 数据结构与内存管理策略(下) 标签: Redis Redis数据结构 Redis内存管理策略 Redis数据类型 Redis类型映射 Redis 数据类型特点与使用场景 String.Li ...
- Redis 数据结构之dict(2)
本文及后续文章,Redis版本均是v3.2.8 上篇文章<Redis 数据结构之dict>,我们对dict的结构有了大致的印象.此篇文章对dict是如何维护数据结构的做个详细的理解. 老规 ...
- [转]Redis 数据结构简介
Redis 数据结构简介 Redis可以存储键与5种不同数据结构类型之间的映射,这5种数据结构类型分别为String(字符串).List(列表).Set(集合).Hash(散列)和 Zset(有序集合 ...
- RedisTemplate访问Redis数据结构
https://www.jianshu.com/p/7bf5dc61ca06 Redis 数据结构简介 Redis 可以存储键与5种不同数据结构类型之间的映射,这5种数据结构类型分别为String(字 ...
- RedisTemplate访问Redis数据结构(介绍和常用命令)
Redis 数据结构简介 Redis 可以存储键与5种不同数据结构类型之间的映射,这5种数据结构类型分别为String(字符串).List(列表).Set(集合).Hash(散列)和 Zset(有序集 ...
- 第18章 Redis数据结构常用命令
18-1 字符串的一些基本命令 18-1 :配置Spring关于Redis字符串的运行环境 <bean id="poolConfig" class="redis.c ...
- redis数据结构、持久化、缓存淘汰策略
Redis 单线程高性能,它所有的数据都在内存中,所有的运算都是内存级别的运算,而且单线程避免了多线程的切换性能损耗问题.redis利用epoll来实现IO多路复用,将连接信息和事件放到队列中,依次放 ...
- 如何使用RedisTemplate访问Redis数据结构之字符串操作
Redis 数据结构简介 Redis 可以存储键与5种不同数据结构类型之间的映射,这5种数据结构类型分别为String(字符串).List(列表).Set(集合).Hash(散列)和 Zset(有序集 ...
- 5种Redis数据结构详解
本文主要和大家分享 5种Redis数据结构详解,希望文中的案例和代码,能帮助到大家. 转载链接:https://www.php.cn/php-weizijiaocheng-388126.html 2. ...
随机推荐
- [VBS]带参数删除扩展名不是*.h、*.c、*.cpp的全部文件
脚本使用例程CleanFolder遍历一个文件夹 1)使用CleanFolder递归遍历该文件夹下的所有子文件夹 2)如果该子文件夹的大小为0,则删除这个文件夹 3)遍历该文件夹下的所有文件,扩展名不 ...
- CoreLocation框架的使用---定位,求两地距离
前言: 在iOS开发中,有关导航,周边的开发,必须基于2个框架: Map Kit :用于地图展示 Core Location :用于地理定位 用户隐私的保护 从iOS 6开始,苹果在保护用户隐私方 ...
- Spring MVC+Spring +Hibernate配置事务,但是事务不起作用
最近做项目,被一个问题烦恼了很久.使用Spring MVC+Spring +Hibernate开发项目,在使用注解配置事务管理,刚开始发现无论如何数据库都无法更新,但是可以从数据库查询到数据.怀疑是配 ...
- Druid的使用步骤
一.关于Druid Druid是一个JDBC组件,它包括三部分: DruidDriver 代理Driver,能够提供基于Filter-Chain模式的插件体系. DruidDataSource 高效可 ...
- [php-composer] how to install composer in windows
Composer Setup 1. Choose the command-line PHP you want to use.选择使用可以命令行的PHP程序 2. proxy Settings - ch ...
- [ASE][Daily Scrum]11.13
今天的计划如下: View Shilin Liu 修复残缺地图下的行进问题 Client Jiafan Zhu(回学校了) 和服务器端对接测试 Yiming Liao ...
- 【基础知识】.Net基础加强08天
一. 文件的读取 1. 有FileStrem,为什么还要StreamWriter和StreamRead StreamWriter和StreamRead是用来读取文本文件的,每次只读取一行文本文件 二. ...
- C#函数式编程之部分应用
何谓函数式编程 相信大家在实际的开发中,很多情况下完成一个功能都需要借助多个类,那么我们这里的基本单元就是类.而函数式编程则更加细化,致使我们解决一个功能的基本单元是函数,而不是类,每个功能都是由多个 ...
- 大熊君说说JS与设计模式之------命令模式Command
一,总体概要 1,笔者浅谈 日常生活中,我们在看电视的时候,通过遥控器选择我们喜欢的频道时,此时我们就是客户端的角色,遥控器的按钮相当于客户请求,而具体执行的对象就是命令对象, 命令模式把一个请求或者 ...
- 设计模式之美:Builder(生成器)
索引 意图 结构 参与者 适用性 效果 相关模式 实现 实现方式(一):Builder 为每个构件定义一个操作. 实现方式(二):Builder 将构件返回给 Director,Director 将构 ...