简体   繁体   中英

Serializer for Value which holds Set<String> in redis

I have to store Set as value in my redis. I am not able to figure out how to serialize it and set in the below object

RedisTemplate<String,Set<String>> redisTemplate = new RedisTemplate<String, Set<String>>();
redisTemplate.setHashValueSerializer(NEED_A_HASH_VALUE_SERIALIZER_HERE);
redisTemplate.setValueSerializer(NEED_A_VALUE_SERIALIZER_HERE);

Need some help here

You can use lpush or rpush in redis to push your strings into an array in redis and retrive it using the following method.

List<String> result = cacheClient.getLRange("FRE_TRIG_WL", 0, -1);
HashSet<String> wl = new HashSet<String>(result);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM