mirror of
https://github.com/keven1024/015.git
synced 2026-05-30 08:59:34 +00:00
32 lines
790 B
Go
32 lines
790 B
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
"pkg/utils"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
func GetRedisFileShareRelational(fileId string) ([]string, error) {
|
|
rdb, ctx := utils.GetRedisClient()
|
|
fileShareRelationalUnmarshalData, err := rdb.HGet(ctx, "015:fileShareRelational", fileId).Result()
|
|
if err == redis.Nil {
|
|
return nil, nil
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var shareIDs []string
|
|
if err := json.Unmarshal([]byte(fileShareRelationalUnmarshalData), &shareIDs); err != nil {
|
|
return nil, err
|
|
}
|
|
return shareIDs, nil
|
|
}
|
|
|
|
func SetRedisFileShareRelational(fileId string, shareIDs []string) error {
|
|
rdb, ctx := utils.GetRedisClient()
|
|
jsonData, _ := json.Marshal(shareIDs)
|
|
_, err := rdb.HSet(ctx, "015:fileShareRelational", fileId, string(jsonData)).Result()
|
|
return err
|
|
}
|