|
|
@@ -1,5 +1,6 @@
|
|
|
package com.tzld.piaoquan.recommend.feature.produce.service;
|
|
|
|
|
|
+import com.google.common.reflect.TypeToken;
|
|
|
import com.tzld.piaoquan.recommend.feature.produce.model.DTSConfig;
|
|
|
import com.tzld.piaoquan.recommend.feature.produce.util.CompressionUtil;
|
|
|
import com.tzld.piaoquan.recommend.feature.produce.util.JSONUtils;
|
|
|
@@ -11,10 +12,7 @@ import redis.clients.jedis.Pipeline;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
@@ -47,7 +45,10 @@ public class RedisService implements Serializable {
|
|
|
String redisKey = redisKey(record, config);
|
|
|
|
|
|
Map<String, String> valueMap = new HashMap<>();
|
|
|
- if (CollectionUtils.isNotEmpty(config.getRedis().getValue())) {
|
|
|
+ if (StringUtils.isNotBlank(config.getRedis().getFeatureField())) {
|
|
|
+ record = JSONUtils.fromJson(record.get(config.getRedis().getFeatureField()), new TypeToken<Map<String, String>>() {
|
|
|
+ }, Collections.emptyMap());
|
|
|
+ }else if (CollectionUtils.isNotEmpty(config.getRedis().getValue())) {
|
|
|
for (String valueKey : config.getRedis().getValue()) {
|
|
|
valueMap.put(valueKey, record.get(valueKey));
|
|
|
}
|
|
|
@@ -85,13 +86,6 @@ public class RedisService implements Serializable {
|
|
|
|
|
|
Pipeline pipeline = jedis.pipelined();
|
|
|
for (Map.Entry<String, String> e : batch.entrySet()) {
|
|
|
- // pipeline.setex(e.getKey(), expireSeconds, e.getValue());
|
|
|
- // 压缩后的key,升级后进行替换
|
|
|
- // try {
|
|
|
- // pipeline.setex(e.getKey(), expireSeconds, CompressionUtil.snappyCompress(e.getValue()));
|
|
|
- // } catch (Exception ex) {
|
|
|
- // }
|
|
|
- //
|
|
|
try {
|
|
|
String newKey = String.format("%s:v2", e.getKey());
|
|
|
pipeline.setex(newKey.getBytes(StandardCharsets.UTF_8), expireSeconds, CompressionUtil.snappyCompressV2(e.getValue()));
|