redis sentry
Website : https://redis.io/
explain : The cache server can effectively improve the access efficiency of users
1. matters needing attention :
A: The data structure of cache should be selected as K-V structure , as long as K Only then the result must be the same
B: It's impossible to cache the total data all the time , Memory data needs to be optimized periodically ,LRU Algorithm ....
C: The running data of cache should be fast ,C Language implementation ... Running in memory
D: If the data of the cache run is in memory , Add power failure or downtime , Memory data is lost directly loss ; Realize the persistence operation of memory data ( disk )
2.Redis Cache server :
Concept : It's an open source , Data structure storage system in memory , It can be used in databases , Caching and message middleware ; Support multiple types of data structures . Such as : character string (string) hash (hashes) list (list) aggregate (sets) Ordered set (sorted sets);
3.Redis Installation
A: Get into src root directory => Upload compressed package => perform tar -zxvf redis-5.0.4.tar.gz Unzip the file => Modify the file storage location => mv redis-5.0.4 redis Change the file name ;
B: install redis Get into redis root directory cd redis => make ( compile ) => make install( install )
4.Redis.conf Modification of configuration file :
(bind 127.0.0.1 Express ip binding )
First step : Note binding address
The second step :yes Change to no
The third step : Turn on background start no Change to yes
A: Enter the following directory => open redis.conf
5.Redis Start of :
A: start-up Redis: stay redis Follow directory redis-server redis.conf
B: Check the process ps -ef |grep redis
C: Get into redis client :redis-cli -p 6379 (-p Represents the port number )
D:set key vail form
E: close redis: Two ways
1. direct kill
2.reis-cli -p 6379 shutdown
6.Redis The order of :
1.String type
2.Hash type
explain : You can use hash types to hold object and property values
Example :User object {id:2,name: Xiao Ming ,age:19}
3.List type
explain :Redis Medium List A set is a double ended loop list , Data can be inserted from left and right directions respectively .
List Collections can be used as queues , It can also be used as a stack
queue : The direction of storing data is opposite to that of obtaining data
Stack : The direction of storing data is the same as that of obtaining data
4.Redis Business order
explain :redis Operations in can add transaction support . A task can consist of more than one redis Command complete , If there is a command failure that causes the storage failure . Need to implement transaction rollback .
6.Redis Integration of mybatis
A: add to jar package
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
B: Test for connectivity :
C:setnx(k, v); senior api Determine if the data exists If there is data, it is not processed
D:setex(k, Time ,v) ( Set failure time and set value ) Method execution either succeeds or fails ;
jedis.setex("2007",100," Test time )
E:jedis.set