当前位置:网站首页>Binary array command of redis
Binary array command of redis
2022-06-26 16:07:00 【Hua Weiyun】
redis Binary array command
redis The binary array of is in SDS To represent the ,sds Of len The value of the property represents SDS How many byte long bit groups are saved ,buf Each byte of the array is represented by a row , Each row 8 And the array is stored in reverse order
getbit command
getbit The command obviously returns the value of the binary bits of the specified offset of the bit array ,
redis> GETBIT bit 10086(integer) 1
The execution process is to divide the offset by 8 The binary bits specified by the calculated offset are stored in the byte of the bit array , Then offset mod8 Add another one to calculate the number of bits in the binary system , Get the value of this bit and return
setbit command
setbit The command is to set a new value for the specified offset , And return the old value . If the offset is greater than the current one, it will be expanded
redis> SETBIT bit 10086 1(integer) 0
bitcount command
bitcount The command is used to count the values in an array 1 The number of
redis> BITCOUNT bits(integer) 0redis> SETBIT bits 0 1 # 0001(integer) 0redis> BITCOUNT bits(integer) 1redis> SETBIT bits 3 1 # 1001(integer) 0redis> BITCOUNT bits(integer) 2
bitcount Implementation of commands redis Table lookup method and Hamming algorithm are used , The number of binary bits is greater than or equal to 128 Bit uses Hamming Algorithm , Less than 128 Bit use look-up table .
bitop and Is to carry out and operate
bitop or To do or operate
bitop xor Is an XOR operation
bitop not Yes no operation
summary
This article mainly introduces redis Binary array of ,redis The binary array of SDS To express ,getbit Command returns the value of the binary bit of the specified offset of the bit array ,setbit The command sets a new value for the specified offset , And return the old value ,bitcount The command counts the values in the array as 1 The number of , When the number of binary bits is greater than or equal to 128 Bit using Hamming algorithm , Less than 128 Bit using the look-up table method ,bitop Command performs bit operations on binary arrays , It has various parameters ,and Representation and operation ,or To express or operate ,xor The XOR operation indicates ,not Indicates non operation , These commands are all commands that operate on binary arrays , Mastering binary array commands can make us more familiar with redis Binary array of .
️ Thank you for your
If you think this is helpful for you :
- Welcome to follow me ️, give the thumbs-up , Comment on , forward
- Focus on
Panpan small class
, Push good articles for you regularly , There are also group chat and irregular lottery activities , You can say what you want , Communicate with the great gods , Learning together . - If there is anything inappropriate, you are welcome to criticize and correct .
边栏推荐
- 手写数字体识别,用保存的模型跑自己的图片
- Keepalived 实现 Redis AutoFailover (RedisHA)1
- Simple use of tensor
- Redis migration (recommended operation process) 1
- (1) Keras handwritten numeral recognition and recognition of self written numbers
- Angel 3.2.0 new version released! Figure the computing power is strengthened again
- 5000 word analysis: the way of container security attack and defense in actual combat scenarios
- C语言读取数据
- PCIe Capabilities List
- Anaconda3 installation tensorflow version 2.0 CPU and GPU installation, win10 system
猜你喜欢
Handwritten numeral recognition, run your own picture with the saved model
理想路径问题
svg野人动画代码
首例猪心移植细节全面披露:患者体内发现人类疱疹病毒,死后心脏重量翻倍,心肌细胞纤维化丨团队最新论文...
Application of ansible automation
Comprehensive analysis of discord security issues
Net基于girdview控件实现删除与编辑行数据
How to identify contractual issues
NFT 平台安全指南(1)
9 Tensorboard的使用
随机推荐
svg canvas画布拖拽
Development, deployment and online process of NFT project (2)
NFT transaction principle analysis (2)
2 three modeling methods
(一)keras手写数字体识别并识别自己写的数字
Swiftui retrieves the missing list view animation
Solidus labs welcomes zhaojiali, former head of financial innovation in Hong Kong, as a strategic adviser
C# 读写文件从用户态切到内核态,到底是个什么流程?
【思考】在买NFT的时候你在买什么?
若依打包如何分离jar包和资源文件?
9 Tensorboard的使用
JS creative icon navigation menu switch background color
When a project with cmake is cross compiled to a link, an error cannot be found So dynamic library file
Solana扩容机制分析(1):牺牲可用性换取高效率的极端尝试 | CatcherVC Research
Exquisite makeup has become the "soft power" of camping, and the sales of vipshop outdoor beauty and skin care products have surged
Tsinghua's "magic potion" is published in nature: reversing stem cell differentiation, and the achievements of the Nobel Prize go further. Netizen: life can be created without sperm and eggs
STEPN 新手入門及進階
R语言广义线性模型函数GLM、glm函数构建逻辑回归模型(Logistic regression)、分析模型是否过离散(Overdispersion)、使用残差偏差与二项式模型中的剩余自由度的比率评估
H5 close the current page, including wechat browser (with source code)
零知识 QAP 问题的转化