mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 08:29:33 +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
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package mcache
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"time"
 | |
| 
 | |
| 	"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/openimsdk/tools/s3/minio"
 | |
| )
 | |
| 
 | |
| func NewMinioCache(cache database.Cache) minio.Cache {
 | |
| 	return &minioCache{
 | |
| 		cache:      cache,
 | |
| 		expireTime: time.Hour * 24 * 7,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| type minioCache struct {
 | |
| 	cache      database.Cache
 | |
| 	expireTime time.Duration
 | |
| }
 | |
| 
 | |
| func (g *minioCache) getObjectImageInfoKey(key string) string {
 | |
| 	return cachekey.GetObjectImageInfoKey(key)
 | |
| }
 | |
| 
 | |
| func (g *minioCache) getMinioImageThumbnailKey(key string, format string, width int, height int) string {
 | |
| 	return cachekey.GetMinioImageThumbnailKey(key, format, width, height)
 | |
| }
 | |
| 
 | |
| func (g *minioCache) 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.cache.Del(ctx, ks)
 | |
| }
 | |
| 
 | |
| func (g *minioCache) DelImageThumbnailKey(ctx context.Context, key string, format string, width int, height int) error {
 | |
| 	return g.cache.Del(ctx, []string{g.getMinioImageThumbnailKey(key, format, width, height)})
 | |
| }
 | |
| 
 | |
| func (g *minioCache) GetImageObjectKeyInfo(ctx context.Context, key string, fn func(ctx context.Context) (*minio.ImageInfo, error)) (*minio.ImageInfo, error) {
 | |
| 	return getCache[*minio.ImageInfo](ctx, g.cache, g.getObjectImageInfoKey(key), g.expireTime, fn)
 | |
| }
 | |
| 
 | |
| func (g *minioCache) GetThumbnailKey(ctx context.Context, key string, format string, width int, height int, minioCache func(ctx context.Context) (string, error)) (string, error) {
 | |
| 	return getCache[string](ctx, g.cache, g.getMinioImageThumbnailKey(key, format, width, height), g.expireTime, minioCache)
 | |
| }
 |