当前位置:网站首页>Redis: hash type data operation command
Redis: hash type data operation command
2022-07-04 04:28:00 【dengfengling999】
single key: object ( Property name - Property value ...)
Hash type (hash)
Redis Of hash It's a string Type of key and value Mapping table , there value It's a series of key-value pairs ,hash Ideal for storing objects .
The general idea of hash type data operation is through key and field operation value,key It's a data ID ,field Is domain ,value It's our feeling
Business data of interest .



1.hset
grammar :hset key field value [field value …]
function : Set the key value to field-value Set to Hash list key in , If key non-existent , Then create a new Hash list , The assignment is then performed , If key Under the field Already exist , be value Value override .
Return value : Returns the number of key value pairs successfully set .

for example :

2.hget
grammar :hget key field
function : Get hash table key Given domain in field Value .
Return value :field Domain value , If key Nonexistence or field There is no return nil.

for example :

3.hmset and hset Function as
grammar :hmset key field value [field value…]
function : There will be more than one field-value ( Domain - value ) Set to hash table key in , This command will overwrite the existing field,hash surface key non-existent , Create empty hash surface , Re execution hmset.
Return value : Set successfully returned ok, If it fails, an error is returned .

for example :


4.hmget
grammar :hmget key field [field…]
function : Get hash table key The value of one or more given fields in
Return value : Return and field The value corresponding to the order , If field non-existent , return nil.

for example :
Don't know hsah Medium file Time use :
5.hgetall
grammar :hgetall key
function : Get hash table key All fields and values in
Return value : Return... As a list hash The values of the middle field and the field ,key non-existent , Returns an empty hash.

for example :
6.hdel
grammar :hdel key field [field…]
function : Delete hash table key One or more specified domains in field, non-existent field Direct to ignore .
Return value : Successfully deleted field The number of .

for example :
7.hlen
grammar :hlen key
function : Get hash table key Mesosphere field The number of
Return value : The number ,field The number of .key There is no return 0.

for example :
8.hexists
grammar :hexists key field
function : Look at the hash table key in , Given domain field Whether there is
Return value : If field There is , return 1, Other return 0.

for example :stu1002 above name Has deleted

9.hkeys
grammar :hkeys key
function : Look at the hash table key All in field Domain list
Return value : Contains all the field A list of ,key There is no return empty list

for example :
10.hvals
grammar :hvals key
function : Return hash table List of values for all fields in
Return value : A list of all the field values in the hash table ,key There is no return empty list .
for example :
11.hincrby
grammar :hincrby key field int
function : To the hash table key Medium field Domain addition int
Return value : Returns the added field Domain value

for example :

12.hincrbyfloat
grammar :hincrbyfloat key field float
function : To the hash table key Medium field Domain addition float
Return value : Returns the added field Domain value

for example :
13.hsetnx
grammar :hsetnx key field value
function : Hash table key In the domain field Is set to value , If and only if domain field Set when it doesn't exist , Otherwise, do not set .
Return value : Set value returned successfully 1, Other return 0.

for example :
边栏推荐
- leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
- Katalon uses script to query list size
- Pytest basic self-study series (I)
- (pointeur) Écrivez - vous une fonction qui compare la taille de la chaîne et fonctionne comme strcmp.
- RHCSA 08 - automount配置
- leetcode刷题:二叉树05(翻转二叉树)
- [Logitech] m720
- I.MX6U-ALPHA开发板(模仿STM32驱动开发实验)
- C语言双向链表初版
- [csrf-01] basic principle and attack and defense of Cross Site Request Forgery vulnerability
猜你喜欢

Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal

2021 RSC | Drug–target affinity prediction using graph neural network and contact maps

Leetcode skimming: binary tree 07 (maximum depth of binary tree)

Flink learning 6: programming model

ModStartBlog 现代化个人博客系统 v5.2.0 源码下载

RPC技术

旭化成首次参展第五届中国国际进口博览会(5th CIIE)

PPt 教程,如何在 PowerPoint 中将演示文稿另存为 PDF 文件?

EventBridge 在 SaaS 企业集成领域的探索与实践
![[Logitech] m720](/img/bb/44144a1c3907808398c05b3b36962c.png)
[Logitech] m720
随机推荐
Exercises in quantum mechanics
Pytest basic self-study series (I)
Ppt tutorial, how to save a presentation as a PDF file in PowerPoint?
Architecture practice camp - graduation project of module 9 of phase 6
Parameterization of controls in katalon
Leader: who uses redis expired monitoring to close orders and get out of here!
Leetcode brush question: binary tree 06 (symmetric binary tree)
leetcode:1314. 矩阵区域和【二维前缀和模板】
Architecture training graduation design + summary
Virtual commodity account trading platform source code_ Support personal QR code collection
分布式CAP理论
(pointer) write a function to compare the size of strings by yourself, which is similar to StrCmp.
“找工作不要太在意工资”,这是我听过最大的谎言
I.MX6U-ALPHA开发板(模仿STM32驱动开发实验)
透过JVM-SANDBOX源码,了解字节码增强技术原理
虚拟商品帐号交易平台源码_支持个人二维码收款
leetcode刷题:二叉树06(对称二叉树)
浅谈一篇优质的小红书文案需要具备什么
分布式系统:what、why、how
(pointeur) Écrivez - vous une fonction qui compare la taille de la chaîne et fonctionne comme strcmp.