作品广场优化,将点赞前三和浏览量前三的作品放在第一页的最前面
This commit is contained in:
@@ -7,10 +7,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -154,6 +151,8 @@ public class RedisUtil {
|
||||
return redisTemplate.keys(key);
|
||||
}
|
||||
|
||||
public Long getSize(String key){return redisTemplate.opsForSet().size(key);}
|
||||
|
||||
public List<String> getMultiValue(Set<String> keys){
|
||||
return redisTemplate.opsForValue().multiGet(keys);
|
||||
}
|
||||
@@ -216,4 +215,17 @@ public class RedisUtil {
|
||||
return redisTemplate.opsForValue().increment(key, 0);
|
||||
}
|
||||
|
||||
public Long getViewCount(String key) {
|
||||
Object value = redisTemplate.opsForValue().get(key);
|
||||
if (value instanceof Integer) {
|
||||
return Long.valueOf((Integer) value);
|
||||
} else if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
} else if (value instanceof String) {
|
||||
return Long.valueOf((String) value);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected value type");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user