服务器推荐

master
zhangshanxue 2019-11-05 13:44:04 +08:00
parent 1fc754596a
commit 7d389693b9
2 changed files with 3 additions and 3 deletions

View File

@ -55,7 +55,7 @@ public class GetServerListController extends HttpServlet {
List<DBObject> serverList = new ArrayList<>(); List<DBObject> serverList = new ArrayList<>();
long local = System.currentTimeMillis(); long local = System.currentTimeMillis();
if ((local - lastRefreshTime) > 60 * 1000 || serverInfosCache.isEmpty()) { if ((local - lastRefreshTime) > 10 * 1000 || serverInfosCache.isEmpty()) {
serverInfosCache.clear(); serverInfosCache.clear();
lastRefreshTime = local; lastRefreshTime = local;
recommend = ""; recommend = "";
@ -133,7 +133,7 @@ public class GetServerListController extends HttpServlet {
Map<String, UserRecentLoginInfo> userServerInfoMap = BaseGlobal.getInstance().redisApp.hgetAll(RedisKey.USER_SERVER_INFO, openId, UserRecentLoginInfo.class, -1, false); Map<String, UserRecentLoginInfo> userServerInfoMap = BaseGlobal.getInstance().redisApp.hgetAll(RedisKey.USER_SERVER_INFO, openId, UserRecentLoginInfo.class, -1, false);
DBObject myLastServer = null; DBObject myLastServer = null;
List<String> myServerList = new ArrayList<>(); List<String> myServerList = new ArrayList<>();
int time = 0; long time = 0;
for (Map.Entry<String, UserRecentLoginInfo> entry : userServerInfoMap.entrySet()) { for (Map.Entry<String, UserRecentLoginInfo> entry : userServerInfoMap.entrySet()) {
if(!serverInfosCache.keySet().contains(entry.getKey())){ if(!serverInfosCache.keySet().contains(entry.getKey())){
//服务器已清除 //服务器已清除
@ -141,6 +141,7 @@ public class GetServerListController extends HttpServlet {
} }
myServerList.add(entry.getKey()); myServerList.add(entry.getKey());
if (entry.getValue().getLoginTime() > time) { if (entry.getValue().getLoginTime() > time) {
time =entry.getValue().getLoginTime();
myLastServer = getDBObject(entry.getKey(), entry.getValue()); myLastServer = getDBObject(entry.getKey(), entry.getValue());
} }
} }

View File

@ -42,7 +42,6 @@ public class RedisApp {
public <K, T> T get(final String type, final K key, final Class<T> clazz, final int seconds, public <K, T> T get(final String type, final K key, final Class<T> clazz, final int seconds,
boolean withServerId) throws Exception { boolean withServerId) throws Exception {
String fullKey = getKey(type, key, withServerId); String fullKey = getKey(type, key, withServerId);
System.out.println("-------fullKey---------"+fullKey);
String strValue = redisUtil.get(fullKey); String strValue = redisUtil.get(fullKey);
if (strValue == null) { if (strValue == null) {
return null; return null;