我们的应用程序具有我们从 Maven 项目文件中动态获取的属性。
info:
build:
artifact: @project.artifactId@
name: @project.name@
description: @project.description@
version: @project.version@
Run Code Online (Sandbox Code Playgroud)
当我们使用 Eclipse 时,这些都不是问题,但现在转移到 InelliJ 时,除非我为这些动态属性提供一些硬编码值,否则应用程序将无法启动。
我收到此错误:
19:47:20.962 [main] INFO com.edlogics.ElrcApplication - Spring Boot configuration: profiles = [local, chris]
19:47:20.968 [main] INFO com.edlogics.ElrcApplication - Spring Boot configuration: properties = {}
Exception in thread "main" while scanning for the next token
found character '@' that cannot start any token. (Do not use @ for indentation)
in 'reader', line 74, column 11:
name: @project.name@
^
org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:420)
org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226)
org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:586)
org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) …
Run Code Online (Sandbox Code Playgroud) 我们最近将应用程序升级到 Spring Boot 2 (2.0.3.RELEASE)。随着 Spring Data Redis 的升级,也升级到了 2.0.8.RELEASE。我们从使用 Jedis 切换到 Lettuce,因为启动升级文档说现在这是默认设置。
我将生菜连接池定义为:
spring:
redis:
ssl: true
lettuce:
pool:
max-active: 250
max-idle: 250
min-idle: 50
max-wait: 2000ms
shutdown-timeout: 100ms
Run Code Online (Sandbox Code Playgroud)
今天我注意到在一台开发服务器上,我们在执行 Redis 读/写时遇到了很多线程阻塞。路径如下所示:
io.lettuce.core.internal.AbstractInvocationHandler:invoke:80
|
|__io.lettuce.core.FutureSyncInvocationHandler:handleInvocation:62
|
|__io.lettuce.core.LettuceFutures:awaitOrCancel:112
|
|__io.lettuce.core.protocol.AsyncCommand:await:81
|
|__java.util.concurrent.locks.LockSupport:parkNanos:215
Run Code Online (Sandbox Code Playgroud)
有时我们看到线程等待 2 秒,有时我们看到它等待 19 秒。
我开始研究 Spring Redis 的不同选项,例如管道。
https://github.com/lettuce-io/lettuce-core/wiki/Asynchronous-API
我遇到的问题是我找不到使 LettuceConnection 异步的方法。我看到在管道传输时调用 LettuceConnection.getAsyncConnection() 。据我所知,管道仅在使用 RedisTemplate 时可用。从 Spring Data Redis 2 开始,RedisCacheManager 不再使用 RedisTemplate;它使用 RedisCacheConfiguration。
所以,我的问题是我们如何使用 Spring 缓存抽象 (RedisCacheManager) 进行异步 Redis?