当前位置:网站首页>【Redis】Hash类型
【Redis】Hash类型
2022-06-29 01:56:00 【骑着蜗牛ひ追导弹'】
文章目录
Hash类型
Hash类型,也叫做散列,其value是一个无序字典,类似于java中的HashMap。
相比于String类型将对象序列化为Json字符串,当需要修改某个字段的时候不是很方便;而Hash结构可以将对象中的每个字段独立存储,可以针对单个字段做CRUD:


基本的通用命令如上图所示,下面进行详细介绍!
1.1 HSET & HGET & HMSET & HMGET

HSET key field value:添加或者修改hash类型key的field的值HGET key field:获取一个hash类型key的field的值HMSET:批量添加多个hash类型key的field的值HMGET:批量获取多个hash类型key的field的值

可以看到Hash类型实现了进一层的结构存储

批处理的时候针对单个对象的属性实现也就是每个field

1.2 HGETALL & HKEYS & HVALS

HGETALL:获取一个hash类型的key中的所有的field和valueHKEYS:获取一个hash类型的key中的所有的fieldHVALS:获取一个hash类型的key中的所有的value

1.3 HINCRBY & HINCEBYFLOAT

HINCRBY:按增量递增键处存储的哈希中存储在字段处的数字。如果密钥不存在,则会创建一个包含哈希的新密钥。如果字段不存在,则在执行操作之前将该值设置为0。HINCEBYFLOAT:按指定的增量,将存储在键处并表示浮点数的哈希的指定字段进行increment。如果增量值为负数,则结果是哈希字段值递减,而不是递增。如果出现以下情况之一,则返回错误:该字段包含错误类型的值(不是字符串);当前字段内容或指定的增量不能作为双精度浮点数进行分析.

1.4 HSETNX

仅当字段尚不存在时,才将存储在key to value处的哈希中的字段设置为。如果密钥不存在,则会创建一个包含哈希的新密钥。如果字段已存在,则此操作无效。
- 1如果字段是哈希中的新字段并且设置了值。
- 如果哈希中已存在字段且未执行任何操作,则为0。

1.5 HSTRLEN & HLEN

HSTRLEN:获取一个hash类型的key中值的长度HLEN:获取一个hash类型的key中的所有的field的大小

边栏推荐
- In MySQL database, the two data written when creating tables with foreign keys are the same. Do I copy them or fail to display them
- How to become a senior digital IC Design Engineer (4-5) script: file comparison operation implemented by shell script
- Basic use of Sqlalchemy
- Which is the best billing method for okcc call center
- Near's storage stacking
- Blog publishing test 3
- Would like to ask how to choose a securities firm? Is it safe to open an account online now?
- A full screen gesture adaptation scheme
- Using autogluon to forecast house price
- How to use PN junction to measure temperature?
猜你喜欢

Battle drag method 1: moderately optimistic and build self-confidence (2)

Magic Quadrant of motianlun's 2021 China Database

TypeScript(5)类、继承、多态

Edrawmax mind map, edrawmax organization chart

The metadata request parsing principle of OData XML format applied by SAP ui5 is based on domparser

How to choose source code encryption software

Analysis of sending principle of OData metadata request for SAP ui5 application

C language course design - food warehouse management system

HBuilder左侧工具栏不见了

Large scale visual relationship understanding
随机推荐
Brief description of 802.1x Protocol
Server antivirus
How to become a senior digital IC Design Engineer (4-3)
Advanced installer architect authoring tool
Testing until you're 35? The 35 + test will lead to unemployment?
如何成为一名高级数字 IC 设计工程师(1-1)Verilog 编码语法篇:引言
Exclusive analysis | real situation of software test about resume and interview
0和1的歧义问题
OculusRiftS与Unity.UI的交互(1)-总览
Callback function of unity after importing resources
Learning notes of Lichuang EDA: Copper laying dead zone? isolated island? Dead copper?
How to encrypt the device
Digital IC design, FPGA design written examination questions, answers and analysis of autumn move (1) 2022 Ziguang zhanrui (Part 1)
Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!
How to encrypt anti copy program
MySQL realizes data comparison between two tables by calculating intersection and difference sets
大三下期末考试
如何成为一名高级数字 IC 设计工程师(6-6)数字 IC 验证篇:系统级仿真
In simple terms, server intrusion prevention
Niuke.com Huawei question bank (41~50)