当前位置:网站首页>【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的大小

边栏推荐
- Typescript (4) interface
- PAT甲级真题1165
- Near consensus mechanism
- Pat grade a real problem 1165
- Battle drag method 1: moderately optimistic and build self-confidence (2)
- Scala 基礎 (三):運算符和流程控制
- MySQL realizes data comparison between two tables by calculating intersection and difference sets
- Last week, institutional encryption asset products outflow US $423million, a record high
- I want to buy stocks today, OK? Is it safe to open an account online now?
- PHP hospital network reservation management system source code, hospital consultation reservation registration OA system (commercial or graduation design)
猜你喜欢

SQL splits strings into tables

Large scale visual relationship understanding

TypeScript(7)泛型

SAP ui5 beginner tutorial Part 23 - sorting sort and grouping Group trial version of list control

Stm32l4xx serial port log configuration analysis

Near consensus mechanism

Introduction to UE gameplay 44 (animation import FBX and production standard)
![[机缘参悟-33]:眼见不一定为实,大多数时候“眼见为虚”](/img/60/703a5bc3038d28bcf812415032f240.jpg)
[机缘参悟-33]:眼见不一定为实,大多数时候“眼见为虚”

ASP. Design and implementation of net+sql online alumni list

TypeScript(4)接口
随机推荐
分享自己平时使用的socket多客户端通信的代码技术点和软件使用
How to become a senior digital IC Design Engineer (3-5) tools: Spyglass Technology
TypeScript(4)接口
Niuke.com Huawei question bank (41~50)
Stm32l4xx serial port log configuration analysis
Utiliser kubernets Resource Lock pour compléter son application ha
TypeScript(6)函数
SAP ui5 beginner tutorial Part 23 - sorting sort and grouping Group trial version of list control
Typescript (6) function
牛客网——华为题库(41~50)
7-29 delete substring in string (non KMP)
The left toolbar of hbuilder is missing
In simple terms, server intrusion prevention
[learn FPGA programming from scratch -50]: Vision - how are chips made? The thirteen steps of chip manufacturing.
Introduction to UE gameplay 44 (animation import FBX and production standard)
Analysis of parsing principle of OData metadata request response in SAP ui5 application
Introduction to super dongle scheme
ASP. Design and implementation of net+sql online alumni list
Installing Oracle database in docker
How to become a senior digital IC Design Engineer (6-7) digital IC Verification: debug skills