Skip to content

Commit

Permalink
remove group user cache
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Oct 12, 2019
1 parent 5a04111 commit 0078f14
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions client/src/main/java/cn/wildfirechat/remote/ChatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ public class ChatManager {
private LruCache<String, UserInfo> userInfoCache;
// key = memberId@groupId
private LruCache<String, GroupMember> groupMemberCache;
// key = userId@groupId
private LruCache<String, UserInfo> groupUserCache;

public enum PushType {
Xiaomi(1),
Expand Down Expand Up @@ -388,7 +386,6 @@ private void onGroupMembersUpdate(String groupId, List<GroupMember> groupMembers
}
for (GroupMember member : groupMembers) {
groupMemberCache.remove(groupMemberCacheKey(groupId, member.memberId));
groupUserCache.remove(groupMemberCacheKey(groupId, member.memberId));
}
mainHandler.post(() -> {
for (OnGroupMembersUpdateListener listener : groupMembersUpdateListeners) {
Expand Down Expand Up @@ -1179,7 +1176,6 @@ public boolean connect(String userId, String token) {
this.token = token;
this.userInfoCache = new LruCache<>(1024);
this.groupMemberCache = new LruCache<>(1024);
this.groupUserCache = new LruCache<>(1024);

if (mClient != null) {
try {
Expand Down Expand Up @@ -2411,11 +2407,9 @@ public UserInfo getUserInfo(String userId, String groupId, boolean refresh) {
if (TextUtils.isEmpty(userId)) {
return null;
}
UserInfo userInfo;
UserInfo userInfo = null;
if (!refresh) {
if (!TextUtils.isEmpty(groupId)) {
userInfo = groupUserCache.get(groupMemberCacheKey(groupId, userId));
} else {
if (TextUtils.isEmpty(groupId)) {
userInfo = userInfoCache.get(userId);
}
if (userInfo != null) {
Expand All @@ -2441,8 +2435,6 @@ public UserInfo getUserInfo(String userId, String groupId, boolean refresh) {
} else {
if (TextUtils.isEmpty(groupId)) {
userInfoCache.put(userId, userInfo);
} else {
groupUserCache.put(groupMemberCacheKey(groupId, userId), userInfo);
}
}
return userInfo;
Expand Down Expand Up @@ -2491,8 +2483,6 @@ public List<UserInfo> getUserInfos(List<String> userIds, String groupId) {
if (info != null) {
if (TextUtils.isEmpty(groupId)) {
userInfoCache.put(info.uid, info);
} else {
groupUserCache.put(groupMemberCacheKey(groupId, info.uid), info);
}
}
}
Expand Down Expand Up @@ -3059,7 +3049,6 @@ public void onSuccess() throws RemoteException {
@Override
public void run() {
groupMemberCache.remove(groupMemberCacheKey(groupId, userId));
groupUserCache.remove(groupMemberCacheKey(groupId, userId));
callback.onSuccess();
}
});
Expand Down

0 comments on commit 0078f14

Please sign in to comment.