feat: add redis cache and fanout support
This commit is contained in:
+5
-2
@@ -1069,12 +1069,12 @@ func usersShutdown() {
|
||||
}
|
||||
}
|
||||
|
||||
func usersUpdateUnread(tenantID types.TenantID, uid types.Uid, val int, inc bool) {
|
||||
func usersUpdateUnread(tenantID types.TenantID, uid types.Uid, val int64, inc bool) {
|
||||
if globals.usersUpdate == nil || (val == 0 && inc) {
|
||||
return
|
||||
}
|
||||
|
||||
upd := &UserCacheReq{TenantID: tenantID, UserId: uid, Unread: val, Inc: inc}
|
||||
upd := &UserCacheReq{TenantID: tenantID, UserId: uid, Unread: int(val), Inc: inc}
|
||||
if globals.cluster.isRemoteTopic(types.TopicKey{TenantID: tenantID, Topic: uid.UserId()}) {
|
||||
// Send request to remote node which owns the user.
|
||||
globals.cluster.routeUserReq(upd)
|
||||
@@ -1240,6 +1240,7 @@ func userUpdater() {
|
||||
|
||||
usersCache[key] = uce
|
||||
counts[uid] = uce.unread
|
||||
store.CacheUserUnreadCount(tenantID, uid, uce.unread)
|
||||
}
|
||||
|
||||
if len(dbPending) > 0 {
|
||||
@@ -1287,6 +1288,7 @@ func userUpdater() {
|
||||
}
|
||||
uce.unread = count
|
||||
usersCache[key] = uce
|
||||
store.CacheUserUnreadCount(io.tenantID, uid, count)
|
||||
} else {
|
||||
logs.Warn.Println("users: missing users cache entry after IO completion, uid", uid)
|
||||
}
|
||||
@@ -1416,6 +1418,7 @@ func userUpdater() {
|
||||
if upd.Gone {
|
||||
// User is being deleted. Don't care if there is a record.
|
||||
delete(usersCache, types.UserKey{TenantID: upd.TenantID, User: upd.UserId})
|
||||
store.DeleteCachedUserUnreadCount(upd.TenantID, upd.UserId)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user