redis

xiaoxiao2021-02-28  41

1、分布式缓存Redis介绍

   中文文档:http://www.redis.cn/topics/cluster-tutorial.html

   Redis是Remote Dictionary Server(远程数据服务)的缩写,是一款内存高速缓存数据库。它的数据模型为Key-Value。它支持丰富的数据结构。比如String/List/Hash/Set/SoredSet。

      1、redis官网 https://redis.io/download

      2、新手入门redis在线测试工具:http://try.redis.io/

2、源码编译安装Redis4.x

      简介:使用源码安装Redis4.x和配置外网访问

1、快速安装 https://redis.io/download#installation

                    wgethttp://download.redis.io/releases/redis-4.0.9.tar.gz

                    tar xzf redis-4.0.9.tar.gz

                    cd redis-4.0.9

                    make

启动服务端:src/redis-server (重启配置文件:src/redis-serverredis.conf)

启动客户端:src/redis-cli

关闭服务器 src/redis-cli shutdown

退出当前窗口ctrl+c

 

2、默认是本地访问的,需要开放外网访问

      1)打开redis.conf文件在NETWORK部分修改

注释掉bind 127.0.0.1可以使所有的ip访问redis

修改 protected-mode,值改为no

3、  编译安装过程发生的问题

(1)   redis安装后进行编译make报错:未安装gcc编译器。Yun

 

(2)   redis缺少相关文件:重新安装redis

 

3、SpringBoot2.x整合redis实战讲解

简介:使用springboot-starter整合reids实战

1、资料

官网:

https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/reference/htmlsingle/#boot-features-redis

集群文档:

https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#cluster

2、springboot整合redis相关依赖引入

      <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-data-redis</artifactId>

       </dependency>

3、相关配置文件配置

                    #=========redis基础配置=========

                    spring.redis.database=0

                    spring.redis.host=127.0.0.1

                    spring.redis.port=6390

                    # 连接超时时间单位 ms(毫秒)

                    spring.redis.timeout=3000

                    #=========redis线程池设置=========

                    # 连接池中的最大空闲连接,默认值也是8。

                    spring.redis.pool.max-idle=200

                    #连接池中的最小空闲连接,默认值也是0。

                    spring.redis.pool.min-idle=200

                  # 如果赋值为-1,则表示不限制;pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。

                    spring.redis.pool.max-active=2000

                    # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时

                    spring.redis.pool.max-wait=1000

 

4、常见redistemplate种类讲解和缓存实操(使用自动注入)

1、注入模板

      @Autowired

      private StirngRedisTemplate strTplRedis

 

2、类型String,List,Hash,Set,ZSet

     对应的方法分别是opsForValue()、opsForList()、opsForHash()、opsForSet()、opsForZSet()

                   

 

4、Redis工具类封装讲解和实战

      简介:高效开发方式 Redis工具类封装讲解和实战

             1、常用客户端 https://redisdesktop.com/download

             2、封装redis工具类并操作

 

转载请注明原文地址: https://www.6miu.com/read-2623950.html

最新回复(0)