当前位置:网站首页>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刷题:二叉树09(二叉树的最小深度)
ctf-pikachu-XSS
普源DS1000Z系列数字示波器在通信原理实验中的应用方案
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
User defined path and file name of Baidu editor in laravel admin
Redis:哈希hash类型数据操作命令
Flink学习7:应用程序结构
leetcode:1314. 矩阵区域和【二维前缀和模板】
Architecture practice camp - graduation project of module 9 of phase 6
PPt 教程,如何在 PowerPoint 中将演示文稿另存为 PDF 文件?
随机推荐
Architecture training graduation design + summary
I.MX6U-ALPHA开发板(C语言版本LED驱动实验)
VIM add interval annotation correctly
C语言单向链表练习
陪驾注意事项 这23点要注意!
02 specific implementation of LS command
戳气球和布尔运算问题(巨难)
Dry goods | detailed explanation of webshell Foundation
[webrtc] M98 Ninja build and compile instructions
Touch and take you to implement an EventEmitter
PPt 教程,如何在 PowerPoint 中将演示文稿另存为 PDF 文件?
线程常用的方法
Asynchronous development process - touch your hand and lead you to realize a promise
One click compilation and deployment of MySQL
DP83848+网线热拔插
疫情远程办公经验分享| 社区征文
hbuildx中夜神模拟器的配置以及热更新
[csrf-01] basic principle and attack and defense of Cross Site Request Forgery vulnerability
2020 Bioinformatics | TransformerCPI
(pointer) write a function to compare the size of strings by yourself, which is similar to StrCmp.