当前位置:网站首页>Redis quick start
Redis quick start
2022-07-06 17:20:00 【bestkasscn】
Redis
Concept
redis It is a high-performance non relational database . The storage form is key-value.
Characteristics of non relational database
- There is no correlation between the data
- Data stored in memory
Download and install
- Official website :https://redis.io
- Chinese net :http://www.redis.net.cn
- Decompression can be used directly
- redis.windows.conf: The configuration file
- redis-cli.exe:redis The client of
- redis-server.exe:redis Server side of
The command operation
redis Data structure of
- redis What's stored is :key-value Formatted data , among key All strings ,value Yes 5 Different data structures
- value Data structure of
- String type :string
- Hash type :hash:map Format
- List the type :list:linkedlist Format
- Collection types :set;
- Ordered set type :sortedset
- value Data structure of
- redis What's stored is :key-value Formatted data , among key All strings ,value Yes 5 Different data structures
String type string
- Storage :set key value
- obtain :get key
- Delete :del key
Hash type hash
Storage :hset key field value
obtain :hget key field
hgetall key( Get all field Of value)
Delete :hdel key field
List the type list Head and tail interpolation can be used
Storage :lpush key value( The first interpolation )
rpush key value( The tail interpolation )
obtain :lrange key start end : Scope acquisition
Delete :lpop key Delete the leftmost element , And return the element to
rpop key Delete the rightmost element , And return the element to
Collection types set
- Storage :sadd key value
- obtain :smembers key
- Delete :srem key value
General Command
- keys *: Query all the keys
- type key: Get the key corresponding to value type
- del key: Delete key
Persistence
redis It's a memory database , When redis Server restart , Or restart the computer , Data will be lost , We can redis The data in memory is persisted and saved to the file on the hard disk
redis Persistence mechanism :
RDB: Default mode , There is no need to configure , This mechanism is used by default
At certain intervals , testing key The change of , Then persist the data
AOF: How to log , The operation of each command can be recorded . You can persist data after every operation
Jedis
Introduce dependencies
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.7.0</version> </dependency>
test
public class JedisTest { private Jedis jedis; @BeforeEach void setup(){ // Establishing a connection jedis = new Jedis("127.0.0.1",6379); // Select database jedis.select(0); } @Test void testString(){ // In the data String result = jedis.set("name","zhangsan"); System.out.println("result=" + result); // get data String name = jedis.get("name"); System.out.println("name=" + name); } @AfterEach void tearDown(){ if (jedis != null){ jedis.close(); } } }
SpringDataRedis
Spring-data-redis yes spring Part of a large family , Provided in srping Access through simple configuration in the application redis service , Yes reids Underlying development package (Jedis, JRedis, and RJC) It's highly encapsulated ,RedisTemplate Provides redis Various operations 、 Exception handling and serialization , Support publish subscription , Also on spring 3.1 cache Implemented .
spring-data-redis in the light of jedis The following functions are provided :
Connection pool automatic management , Provides a highly encapsulated “RedisTemplate” class
in the light of jedis There are a lot of api It is classified and packaged , Encapsulate the same type of operation as operation Interface
ValueOperations: Simple K-V operation
SetOperations:set Type data operation
ZSetOperations:zset Type data operation
HashOperations: in the light of map Type of data operation
ListOperations: in the light of list Type of data operation
边栏推荐
- Yao BanZhi and his team came together, and the competition experts gathered together. What fairy programming competition is this?
- 肖申克的救赎有感
- yum install xxx报错
- Akamai anti confusion
- 暑假刷题嗷嗷嗷嗷
- 【逆向】脱壳后修复IAT并关闭ASLR
- Resume of a microservice architecture teacher with 10 years of work experience
- 8086 分段技术
- The "advertising maniacs" in this group of programmers turned Tiktok advertisements into ar games
- After idea installs the plug-in, restart the plug-in and disappear
猜你喜欢
February database ranking: how long can Oracle remain the first?
Flink 解析(四):恢复机制
koa中间件
一个数10年工作经验的微服务架构老师的简历
JVM运行时数据区之程序计数器
Serial serialold parnew of JVM garbage collector
案例:检查空字段【注解+反射+自定义异常】
【逆向】脱壳后修复IAT并关闭ASLR
Interpretation of Flink source code (III): Interpretation of executiongraph source code
Learn the wisdom of investment Masters
随机推荐
Only learning C can live up to expectations top3 demo exercise
MySQL date function
CentOS7上Redis安装
学习投资大师的智慧
复盘网鼎杯Re-Signal Writeup
汇编语言段定义
Activiti directory (I) highlights
關於Stream和Map的巧用
Ruoyi-Cloud 踩坑的BUG
8086 segmentation technology
Eight part essay that everyone likes
yum install xxx报错
MySQL字符串函数
Only learning C can live up to expectations TOP4 S1E6: data type
连接局域网MySql
Take you hand-in-hand to do intensive learning experiments -- knock the level in detail
[VNCTF 2022]ezmath wp
1. JVM入门介绍
Flink源码解读(一):StreamGraph源码解读
DOS function call