mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-04 03:13:15 +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
		
			
				
	
	
		
			60 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package redis
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
	"time"
 | 
						|
 | 
						|
	"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/tools/s3/minio"
 | 
						|
	"github.com/redis/go-redis/v9"
 | 
						|
)
 | 
						|
 | 
						|
func NewMinioCache(rdb redis.UniversalClient) minio.Cache {
 | 
						|
	rc := newRocksCacheClient(rdb)
 | 
						|
	return &minioCacheRedis{
 | 
						|
		BatchDeleter: rc.GetBatchDeleter(),
 | 
						|
		rcClient:     rc,
 | 
						|
		expireTime:   time.Hour * 24 * 7,
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
type minioCacheRedis struct {
 | 
						|
	cache.BatchDeleter
 | 
						|
	rcClient   *rocksCacheClient
 | 
						|
	expireTime time.Duration
 | 
						|
}
 | 
						|
 | 
						|
func (g *minioCacheRedis) getObjectImageInfoKey(key string) string {
 | 
						|
	return cachekey.GetObjectImageInfoKey(key)
 | 
						|
}
 | 
						|
 | 
						|
func (g *minioCacheRedis) getMinioImageThumbnailKey(key string, format string, width int, height int) string {
 | 
						|
	return cachekey.GetMinioImageThumbnailKey(key, format, width, height)
 | 
						|
}
 | 
						|
 | 
						|
func (g *minioCacheRedis) DelObjectImageInfoKey(ctx context.Context, keys ...string) error {
 | 
						|
	ks := make([]string, 0, len(keys))
 | 
						|
	for _, key := range keys {
 | 
						|
		ks = append(ks, g.getObjectImageInfoKey(key))
 | 
						|
	}
 | 
						|
	return g.BatchDeleter.ExecDelWithKeys(ctx, ks)
 | 
						|
}
 | 
						|
 | 
						|
func (g *minioCacheRedis) DelImageThumbnailKey(ctx context.Context, key string, format string, width int, height int) error {
 | 
						|
	return g.BatchDeleter.ExecDelWithKeys(ctx, []string{g.getMinioImageThumbnailKey(key, format, width, height)})
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
func (g *minioCacheRedis) GetImageObjectKeyInfo(ctx context.Context, key string, fn func(ctx context.Context) (*minio.ImageInfo, error)) (*minio.ImageInfo, error) {
 | 
						|
	info, err := getCache(ctx, g.rcClient, g.getObjectImageInfoKey(key), g.expireTime, fn)
 | 
						|
	if err != nil {
 | 
						|
		return nil, err
 | 
						|
	}
 | 
						|
	return info, nil
 | 
						|
}
 | 
						|
 | 
						|
func (g *minioCacheRedis) GetThumbnailKey(ctx context.Context, key string, format string, width int, height int, minioCache func(ctx context.Context) (string, error)) (string, error) {
 | 
						|
	return getCache(ctx, g.rcClient, g.getMinioImageThumbnailKey(key, format, width, height), g.expireTime, minioCache)
 | 
						|
}
 |