Files
VLoop/backend/internal/middleware/redis/cache.go

25 lines
575 B
Go
Raw Normal View History

2025-12-29 04:10:34 +08:00
package redis
import (
"context"
"time"
2026-03-13 15:32:48 +08:00
"github.com/redis/go-redis/v9"
2025-12-29 04:10:34 +08:00
)
func (c *Client) GetBytes(ctx context.Context, key string) ([]byte, error) {
return c.rdb.Get(ctx, key).Bytes()
}
func (c *Client) SetBytes(ctx context.Context, key string, value []byte, ttl time.Duration) error {
return c.rdb.Set(ctx, key, value, ttl).Err()
}
func (c *Client) Del(ctx context.Context, key string) error {
return c.rdb.Del(ctx, key).Err()
}
2026-03-13 15:32:48 +08:00
func (c *Client) MGet(cacheCtx context.Context, cacheKeys ...string) *redis.SliceCmd {
return c.rdb.MGet(cacheCtx, cacheKeys...)
}