初始化hash缓存-get

dev
DongZeLiang 2024-03-30 11:30:04 +08:00
parent 2bc592c87e
commit bee6f5678c
3 changed files with 6 additions and 4 deletions

View File

@ -49,7 +49,7 @@ public interface HashCache <K, HK, HV> extends DecorationKey<K> {
* @param hashKeyList hash * @param hashKeyList hash
* @return hash * @return hash
*/ */
public HV get(K key, HK... hashKeyList); public List<HV> get(K key, HK... hashKeyList);
/** /**
* hash * hash

View File

@ -4,6 +4,7 @@ import com.muyu.common.cache.HashCache;
import com.muyu.common.redis.service.RedisService; import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -76,8 +77,9 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
* @return hash * @return hash
*/ */
@Override @Override
public HV get (K key, HK... hashKeyList) { public List<HV> get (K key, HK... hashKeyList) {
return null; List<String> encodeHashKeyList = Arrays.stream(hashKeyList).map(this::encodeHashKey).toList();
return redisService.getMultiCacheMapValue(encode(key), encodeHashKeyList);
} }
/** /**

View File

@ -229,7 +229,7 @@ public class RedisService {
* *
* @return Hash * @return Hash
*/ */
public <T> List<T> getMultiCacheMapValue (final String key, final Collection<Object> hKeys) { public <T> List<T> getMultiCacheMapValue (final String key, final Collection<?> hKeys) {
return redisTemplate.opsForHash().multiGet(key, hKeys); return redisTemplate.opsForHash().multiGet(key, hKeys);
} }