|
|
@@ -13,6 +13,7 @@ import org.springframework.data.redis.connection.RedisConnection;
|
|
|
import org.springframework.data.redis.core.RedisCallback;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.data.redis.core.SetOperations;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.data.redis.core.ValueOperations;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -32,6 +33,10 @@ public class RedisManager {
|
|
|
@Autowired
|
|
|
private RedisTemplate<Object,Object> redisTemplate;
|
|
|
|
|
|
+ /** 用于读取交易所写入的纯字符串行情数据(如 ExchangeNew2:latestPrice) */
|
|
|
+ @Autowired
|
|
|
+ private StringRedisTemplate stringRedisTemplate;
|
|
|
+
|
|
|
@Resource(name = "redisTemplate")
|
|
|
private ValueOperations<Object,Object> valOps;
|
|
|
|
|
|
@@ -634,8 +639,10 @@ public class RedisManager {
|
|
|
}
|
|
|
try {
|
|
|
// field 格式:ibitusdt(全小写,直接拼接 usdt)
|
|
|
+ // 使用 StringRedisTemplate 读取,因为交易所写入的是纯字符串,
|
|
|
+ // 用 redisTemplate(JDK/Jackson 序列化)读取会导致反序列化失败
|
|
|
String field = coinUnit.trim().toLowerCase() + "usdt";
|
|
|
- Object val = redisTemplate.opsForHash().get(SPOT_LATEST_PRICE_KEY, field);
|
|
|
+ Object val = stringRedisTemplate.opsForHash().get(SPOT_LATEST_PRICE_KEY, field);
|
|
|
if (val != null) {
|
|
|
java.math.BigDecimal price = new java.math.BigDecimal(val.toString());
|
|
|
if (price.compareTo(java.math.BigDecimal.ZERO) > 0) {
|