Java Code Examples for org.springframework.data.redis.core.ZSetOperations#range()
The following examples show how to use
org.springframework.data.redis.core.ZSetOperations#range() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LikeServiceImpl.java From pcc-like with Apache License 2.0 | 6 votes |
@Override public List<Long> likeUserIdsWithFriendsFirst(int start, int pageCount, Long feedId, Long uid) { if (feedId == null) { return Collections.emptyList(); } ZSetOperations<String, String> feedLikes = this.template.opsForZSet(); // 求交集,得到好友关系 feedLikes.intersectAndStore(KEY_FEED_LIKE + feedId, UserServiceImpl.KEY_USER_FRIENDS + uid, KEY_FEED_LIKE_FRIENDS + feedId); Set<String> friends = feedLikes.range(KEY_FEED_LIKE_FRIENDS + feedId, start, start + pageCount); if (friends.size() > pageCount) { return transfer(friends); } else { // TODO // 剩下的,全部遍历,然后检查是否是好友,如果是,直接排除。如果不是,增加到列表中; // 由于涉及到分页,需要记录上次操作的index } return Collections.emptyList(); }
Example 2
Source File: LikeServiceImpl.java From pcc-like with Apache License 2.0 | 5 votes |
@Override public List<Long> likeUserIds(int start, int pageCount, Long feedId) { if (feedId == null) { return Collections.emptyList(); } ZSetOperations<String, String> feedLikes = this.template.opsForZSet(); Set<String> uids = feedLikes.range(KEY_FEED_LIKE + feedId, start, start + pageCount - 1); return transfer(uids); }