Detailed instructions on the use of sortset (unordered collection) in redissonClient

Get RedissonSortedSet instance

RSortedSet<String> sortedSet = redissonClient.getSortedSet("my_sorted_set");

Add element

sortedSet.add(1, "value1");
sortedSet.add(2, "value2");
sortedSet.addAll(Collections.singletonMap(3d, "value3"));

Get the number of elements

int size = sortedSet.size();

Get the element at the specified position

String value = sortedSet.get(1);

Remove element

sortedSet.remove("value4");
sortedSet.removeAll(Arrays.asList("value5", "value6"));

Close the RedissonClient instance

redissonClient.shutdown();       

Please note that the Sorted Set score in the above example must be of Double type, and the elements in the set can be sorted and range searched based on the score.​ 

Guess you like

Origin blog.csdn.net/weixin_60246228/article/details/134012588