|
@@ -4,6 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
@Component
|
|
|
public class RedisUtils {
|
|
|
|
|
@@ -14,7 +16,23 @@ public class RedisUtils {
|
|
|
return redisTemplate.opsForValue().get(key);
|
|
|
}
|
|
|
|
|
|
- public void set(String key, String value) {
|
|
|
+ public void set(String key, Object value) {
|
|
|
redisTemplate.opsForValue().set(key, value);
|
|
|
}
|
|
|
+
|
|
|
+ public Object getMap(String key, String subKey) {
|
|
|
+ return redisTemplate.opsForHash().get(key, subKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Long decr(String key) {
|
|
|
+ return redisTemplate.opsForValue().decrement(key);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setMap(String key, String subKey, Object subValue) {
|
|
|
+ redisTemplate.opsForHash().put(key, subKey, subValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setAllMap(String key, Map<String, Object> map) {
|
|
|
+ redisTemplate.opsForHash().putAll(key, map);
|
|
|
+ }
|
|
|
}
|