l-export-async/redis.go

30 lines
752 B
Go

package l_export_async
import (
"context"
"time"
"github.com/redis/go-redis/v9"
)
type redisTaskStore struct {
client *redis.Client
}
func (r *redisTaskStore) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) TaskErr {
return r.client.Set(ctx, key, value, expiration)
}
func (r *redisTaskStore) Del(ctx context.Context, keys ...string) TaskErr {
//实际运行中并没有去执行这个,因为不确定是否真的需要删除,如果需要可以自行写入
return r.client.Del(ctx, keys...)
}
func (r *redisTaskStore) Get(ctx context.Context, key string) TaskGet {
return r.client.Get(ctx, key)
}
func NewRedisTaskStore(client *redis.Client) TaskSaveTool {
return &redisTaskStore{client: client}
}