初始化hash缓存-get
parent
41d4175d23
commit
e1d039804c
|
@ -26,7 +26,7 @@ public interface HashCache <K, HK, HV> extends DecorationKey<K> {
|
|||
* @param redisHashKey 数据库键
|
||||
* @return ID
|
||||
*/
|
||||
public K decodeHashKey(String redisHashKey);
|
||||
public HK decodeHashKey(String redisHashKey);
|
||||
|
||||
/**
|
||||
* 通过Key获取所有的map
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.muyu.common.cache.abs;
|
||||
|
||||
import com.muyu.common.cache.HashCache;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
@ -13,6 +16,9 @@ import java.util.function.Function;
|
|||
*/
|
||||
public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*
|
||||
|
@ -42,7 +48,10 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
|
|||
*/
|
||||
@Override
|
||||
public Map<HK, HV> get (K key) {
|
||||
return null;
|
||||
Map<String, HV> dataMap = redisService.getCacheMap(encode(key));
|
||||
Map<HK, HV> resultMap = new HashMap<>();
|
||||
dataMap.forEach((hashKey, hashValue) -> resultMap.put(decodeHashKey(hashKey), hashValue));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue