mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-04 11:22:10 +08:00 
			
		
		
		
	* pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * upgrading pkg tools * fix * fix * optimize log output * feat: support GetLastMessage * feat: support GetLastMessage * feat: s3 switch * feat: s3 switch * fix: GetUsersOnline * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: seq conversion failed without exiting * monolithic * fix: DeleteDoc crash * fix: DeleteDoc crash * fix: monolithic * fix: monolithic * fix: fill send time * fix: fill send time * fix: crash caused by withdrawing messages from users who have left the group * fix: mq * fix: mq * fix: user msg timestamp * fix: mq * 1 * 1 * 1 * 1 * 1 * 1 * 1 * seq read config * seq read config * 1 * 1 * fix: the source message of the reference is withdrawn, and the referenced message is deleted * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1
		
			
				
	
	
		
			66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package redis
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
	"time"
 | 
						|
 | 
						|
	"github.com/openimsdk/open-im-server/v3/pkg/common/config"
 | 
						|
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
 | 
						|
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
 | 
						|
	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
 | 
						|
	"github.com/redis/go-redis/v9"
 | 
						|
)
 | 
						|
 | 
						|
const (
 | 
						|
	blackExpireTime = time.Second * 60 * 60 * 12
 | 
						|
)
 | 
						|
 | 
						|
type BlackCacheRedis struct {
 | 
						|
	cache.BatchDeleter
 | 
						|
	expireTime time.Duration
 | 
						|
	rcClient   *rocksCacheClient
 | 
						|
	blackDB    database.Black
 | 
						|
}
 | 
						|
 | 
						|
func NewBlackCacheRedis(rdb redis.UniversalClient, localCache *config.LocalCache, blackDB database.Black) cache.BlackCache {
 | 
						|
	rc := newRocksCacheClient(rdb)
 | 
						|
	return &BlackCacheRedis{
 | 
						|
		BatchDeleter: rc.GetBatchDeleter(localCache.Friend.Topic),
 | 
						|
		expireTime:   blackExpireTime,
 | 
						|
		rcClient:     rc,
 | 
						|
		blackDB:      blackDB,
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func (b *BlackCacheRedis) CloneBlackCache() cache.BlackCache {
 | 
						|
	return &BlackCacheRedis{
 | 
						|
		BatchDeleter: b.BatchDeleter.Clone(),
 | 
						|
		expireTime:   b.expireTime,
 | 
						|
		rcClient:     b.rcClient,
 | 
						|
		blackDB:      b.blackDB,
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func (b *BlackCacheRedis) getBlackIDsKey(ownerUserID string) string {
 | 
						|
	return cachekey.GetBlackIDsKey(ownerUserID)
 | 
						|
}
 | 
						|
 | 
						|
func (b *BlackCacheRedis) GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error) {
 | 
						|
	return getCache(
 | 
						|
		ctx,
 | 
						|
		b.rcClient,
 | 
						|
		b.getBlackIDsKey(userID),
 | 
						|
		b.expireTime,
 | 
						|
		func(ctx context.Context) ([]string, error) {
 | 
						|
			return b.blackDB.FindBlackUserIDs(ctx, userID)
 | 
						|
		},
 | 
						|
	)
 | 
						|
}
 | 
						|
 | 
						|
func (b *BlackCacheRedis) DelBlackIDs(_ context.Context, userID string) cache.BlackCache {
 | 
						|
	cache := b.CloneBlackCache()
 | 
						|
	cache.AddKeys(b.getBlackIDsKey(userID))
 | 
						|
 | 
						|
	return cache
 | 
						|
}
 |