当前位置:网站首页>Redis core configuration and advanced data types
Redis core configuration and advanced data types
2022-06-12 14:07:00 【Xiao Zhong wants to learn!!!】
Redis Core configuration and advanced data types
Make changes in the configuration file
1、 Basic server settings
Server settings
Set the server to run as a daemons
daemonize yes|noBind host address
bind 127.0.0.1Set the server port number
port 6379Set the number of databases
databases 16
Log configuration
Be careful : The log level development period is set to verbose that will do , In the production environment, the configuration is notice, Simplify log output , Reduce write log IO The frequency of
Set up the server to specify the logging level
loglevel debug|verbose|notice|warningLog file name
logfile Port number .log
Client configuration
Sets the maximum number of client connections at one time , Default limit . When the client connection reaches the upper limit ,Redis Will close the new connection
maxclients 0The maximum waiting time of idle client , Close the connection when the maximum value is reached . To turn off the function , Set to 0
timeout 300
Multi server quick configuration
Import and load the specified profile information , Used to quickly create redis There are more public facilities redis Instance configuration file , Easy to maintain
include /path/server- Port number .conf
2、 Advanced data types
1、Bitmaps
Bitmaps Type of basic operation
Get specified key Corresponding to... On the offset bit value
getbit key offset
Set the specified key Corresponding to... On the offset bit value ,value Can only be 1 or 0
setbit key offset value
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-rPQupGWD-1654998011431)(images/image-20220612082913910.png)]](https://img-blog.csdnimg.cn/723f0106fbb24a32872071f779d982ee.png)
Bitmaps Type extension operation
Business scenario
Movie website
- Count whether a movie is on demand every day
- Count how many movies are on demand every day
- Statistics weekly / month / How many films were on demand in
- Count which movies are not on demand in the year
Business analysis
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-a1PL2Hm5-1654998011432)(images/image-20220612083850544.png)]](/img/f2/7d38bae7378ca1feff8948831c7150.png)
Bitmaps Type extension operation
Specify key Hand in by position 、 and 、 Not 、 Exclusive or operation , And save the result to destKey in
bitop op destKey key1 [key2...] # and: hand over # or: and # not: Not # xor: Exclusive orSpecify Statistics key in 1 The number of
bitcount key [start end]
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-C69KSnih-1654998011432)(images/image-20220612084313008.png)]](/img/1b/8b49e37742671babd31613788a9b3f.png)
redis Apply to information status system
2、HyperLogLog
Statistical independence UV
- The original plan :set Store each user's id( character string )
- The improved scheme :Bitmaps Store each user state (bit)
- A new solution :Hyperloglog
base
- Cardinality is the data set to
After heavyElement number - HyperLogLog It is used for cardinality Statistics , Use of the LogLog The algorithm of
HyperLogLog Type of basic operation
# Add data
pfadd key element [element ...]
# statistics
pfcount key [key ...]
# Merge data
pfmerge destkey sourcekey [sourcekey...]
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-9hxhBfE7-1654998011433)(images/image-20220612090519612.png)]](/img/11/fedbf3b36943ea076afe871f1e120c.png)
redis Applied to independent information statistics
Related instructions
- Used for cardinal Statistics , It's not a collection , Don't save data , Just record the quantity, not the specific data
- The core is
Cardinality estimation algorithm, There is a certain error in the final value - Error range : The result of cardinality estimation is a function with 0.81% Approximate value of standard error
- Minimal space consumption , Every hyperloglog key Occupied 12K Memory used to mark cardinality
- pfadd Command is not a one-time assignment 12K Memory usage , As the base increases, the memory increases
- Pfmerge The storage space occupied after command merging is 12K, Regardless of the amount of data before merging
3、GEO
redis Applied to geographic location calculation
GEO Type of basic operation
# Add coordinate points
geoadd key longitude latitude member [longitude latitude member ...]
# Get coordinate points
geopos key member [member ...]
# Calculate the distance between coordinate points
geodist key member1 member2 [unit]
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-4h5c9Dlf-1654998011433)(images/image-20220612091335668.png)]](/img/13/fddc211149c47dd033cbd69687a796.png)
GEO Type of basic operation 2
# Add coordinate points
georadius key longitude latitude radius m|km|ft|mi [withcoord] [withdist] [withhash] [count count]
# Get coordinate points
georadiusbymember key member radius m|km|ft|mi [withcoord] [withdist] [withhash] [count count]
# Calculate latitude and longitude
geohash key member [member ...]
Example of setting range
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-KLUYlmco-1654998011434)(images/image-20220612092357062.png)]](/img/98/8dec21a55219b9c601977144e0241d.png)
Get the information within the distance
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-PJSsIYYz-1654998011435)(images/image-20220612092438089.png)]](/img/81/64e63a5fd195de67c0efbf1cbb284f.png)
边栏推荐
- [video lesson] a full set of tutorials on the design and production of Android studio Internet of things app -- all mastered during the National Day
- Remote code injection
- WinDbg preview debug analysis createtoolhelp32snapshot
- How test engineers transform test and open
- 1414. minimum number of Fibonacci numbers with sum K
- 2022版Redis数据删除策略
- Display logs in the database through loganalyzer
- M1 pod install pod lint failure solution
- Llvm 13.1 new pass plug-in form [for win]
- 程序分析与优化 - 6 循环优化
猜你喜欢

聊聊MySQL的10大经典错误

618 entered the second half of the period, apple occupied the high-end market, and the domestic mobile phones finally undercut the price competition

Talk about the top 10 classic MySQL errors

Mold and remainder

A method of quickly creating test window

Display logs in the database through loganalyzer

Leetcode 2185. 统计包含给定前缀的字符串

正点原子STM32F429核心板的插座型号

After reading the question, you will point to offer 16 Integer power of numeric value

Transmission and response of events and use cases
随机推荐
Formal analysis of Woo Lam protocol with scyther tool
Create a small root heap and judge the node relationship (also.C\u str() substr(),atoi(),string. Use of find())
Lua common built-in functions
[video lesson] a full set of tutorials on the design and production of Android studio Internet of things app -- all mastered during the National Day
对于跨境电商,更侧重收入的出价策略 —Google SEM
Binary tree traversal
When the byte jumps, the Chinese 996 is output in the United States
1414. minimum number of Fibonacci numbers with sum K
Postgresql14 installation and use tutorial
[semidrive source code analysis] [x9 chip startup process] 25 - Introduction to mailbox inter core communication mechanism (code analysis) rpmsg-ipcc RTOS & QNX
Is Shell Scripting really a big technology?
Programmer interview golden classic good question / interview question 01.05 Edit once
Player screen orientation scheme
3. Process concealment under the ring ----- continuous concealment and new opening prevention
阿里云开发板HaaS510解析串口JSON数据并发送属性
拆改广告机---业余解压
Remote code injection
Acwing: topology sequence
【mysql进阶】mysql索引数据结构的演变(四)
Leetcode 2185. 统计包含给定前缀的字符串