Şöyle yaparız
@Componentpublic class RedisUtil<T> {private RedisTemplate<String, T> redisTemplate;private ValueOperations<String, T> valueOperations;private ListOperations<String, T> listOperations;private SetOperations<String, T> setOperations;private HashOperations<String, Integer, T> hashOperations;@Autowiredpublic RedisUtil(RedisTemplate<String, T> redisTemplate) {this.redisTemplate = redisTemplate;this.valueOperations = redisTemplate.opsForValue();this.listOperations = redisTemplate.opsForList();this.setOperations = redisTemplate.opsForSet();this.hashOperations = redisTemplate.opsForHash();}//region Setpublic void addToSet(String key, T... values) {setOperations.add(key, values);}public Set<T> getSetMembers(String key) {return setOperations.members(key);}//endregion}
Hiç yorum yok:
Yorum Gönder