LJF-Framework 第5章LjfCacheService适配redis测试
一、添加依赖
org.springframework.boot
spring-boot-starter-web
2.6.11
org.springframework.boot
spring-boot-starter-data-redis
2.6.11
com.ljf.plugin
ljf-cache-spring-redis
1.0-SNAPSHOT
com.ljf.framework
ljf-framework
1.0-SNAPSHOT
二、测试启动类
/**
* 描述 :
*
* 版本 作者 时间 内容
* 1.0 lijinfeng 2025-03-17 17:26 create
*/
@SpringBootApplication
public class LjfCacheForRedisTest {
public static void main(String[] args) {
SpringApplication.run(LjfCacheForRedisTest.class, args);
LjfCacheManager.set("username", "lijinfeng", 100L);
}
}
三、yml文件链接redis服务
server:
port: 8001
spring:
application:
# 应用名称
name: ljf-test
# redis配置
redis:
# Redis数据库索引(默认为0)
database: 8
# Redis服务器地址
host: 192.168.147.129
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password: 123456
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池最大连接数
max-active: 200
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 10
# 连接池中的最小空闲连接
min-idle: 0
四、运行启动类
启动成功后,查看redis
我们成功将自己LjfCacheService缓存应用成了redis。