本文整理汇总了Java中org.springframework.data.redis.core.ZSetOperations.TypedTuple方法的典型用法代码示例。如果您正苦于以下问题:Java ZSetOperations.TypedTuple方法的具体用法?Java ZSetOperations.TypedTuple怎么用?Java ZSetOperations.TypedTuple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.redis.core.ZSetOperations
的用法示例。
在下文中一共展示了ZSetOperations.TypedTuple方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getZSetData
import org.springframework.data.redis.core.ZSetOperations; //导入方法依赖的package包/类
protected Map<String, Double> getZSetData(String counterKey) {
Set<ZSetOperations.TypedTuple<String>> rangeWithScore = this.redisTemplate
.boundZSetOps(counterKey).rangeWithScores(0, -1);
Map<String, Double> values = new HashMap<String, Double>(
rangeWithScore.size());
for (Iterator<ZSetOperations.TypedTuple<String>> iterator = rangeWithScore.iterator(); iterator
.hasNext();) {
ZSetOperations.TypedTuple<String> typedTuple = iterator.next();
values.put(typedTuple.getValue(), typedTuple.getScore());
}
return values;
}
示例2: sortByScore
import org.springframework.data.redis.core.ZSetOperations; //导入方法依赖的package包/类
public void sortByScore(List<Post> posts, Set<ZSetOperations.TypedTuple<Long>> scores) {
Map<Long, Double> map = new HashMap<>();
scores.forEach(s -> map.put(s.getValue(), s.getScore()));
posts.sort((o1, o2) -> {
double diff = map.get(o2.getId()) - map.get(o1.getId());
return diff > 0 ? 1 : (diff < 0 ? -1 : 0);
});
}
示例3: getHotPostsOfPage
import org.springframework.data.redis.core.ZSetOperations; //导入方法依赖的package包/类
public List<Post> getHotPostsOfPage(int page, int pageSize) throws PageNotFoundException {
Set<ZSetOperations.TypedTuple<Long>> idsWithScore = hotPostService.getPageWithScore(page, pageSize);
return getHotPostsOfPage(page, idsWithScore);
}
示例4: getPageWithScore
import org.springframework.data.redis.core.ZSetOperations; //导入方法依赖的package包/类
public Set<ZSetOperations.TypedTuple<Long>> getPageWithScore(int page, int pageSize) {
return hotPosts.reverseRangeWithScores(CACHE_HOT_POSTS, page * pageSize, (page + 1) * pageSize - 1);
}
示例5: getPageWithScoreOfTag
import org.springframework.data.redis.core.ZSetOperations; //导入方法依赖的package包/类
public Set<ZSetOperations.TypedTuple<Long>> getPageWithScoreOfTag(Long tagId, int page, int pageSize) {
return hotPosts.reverseRangeWithScores(CACHE_HOT_TAG_POSTS + tagId, page * pageSize, (page + 1) * pageSize - 1);
}
示例6: getPageWithScoreOfTopic
import org.springframework.data.redis.core.ZSetOperations; //导入方法依赖的package包/类
public Set<ZSetOperations.TypedTuple<Long>> getPageWithScoreOfTopic(Long topicId, int page, int pageSize) {
return hotPosts.reverseRangeWithScores(CACHE_HOT_TOPIC_POSTS + topicId, page * pageSize, (page + 1) * pageSize - 1);
}