You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dorm/redis_hash_operation.go

27 lines
710 B

2 years ago
package dorm
import (
"context"
4 months ago
"github.com/redis/go-redis/v9"
2 years ago
)
1 month ago
// HashOperation Hash类型数据操作
2 years ago
type HashOperation struct {
2 years ago
db *redis.Client
2 years ago
}
// NewHashOperation hash类型数据操作 https://www.tizi365.com/archives/296.html
2 years ago
func NewHashOperation(db *redis.Client) *HashOperation {
return &HashOperation{db: db}
2 years ago
}
// Set 根据key和field字段设置field字段的值
2 years ago
func (cl *HashOperation) Set(ctx context.Context, key string, value interface{}) *redis.IntCmd {
return cl.db.HSet(ctx, key, value)
2 years ago
}
// Get 根据key和field字段设置field字段的值
2 years ago
func (cl *HashOperation) Get(ctx context.Context, key, field string) *redis.StringCmd {
return cl.db.HGet(ctx, key, field)
2 years ago
}