refactor: 将redis各个业务分离
This commit is contained in:
18
backend/internal/middleware/redis/cache.go
Normal file
18
backend/internal/middleware/redis/cache.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user