Skip to content

Commit

Permalink
移除耗时日志打印
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Sep 8, 2022
1 parent 926549c commit d22cd6a
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions redisHash.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"github.com/farseer-go/collections"
"github.com/farseer-go/fs/flog"
"github.com/farseer-go/fs/stopwatch"
"github.com/farseer-go/fs/types"
"github.com/go-redis/redis/v8"
"reflect"
Expand Down Expand Up @@ -38,13 +37,10 @@ func (redisHash *redisHash) Get(key string, field string) (string, error) {
// var client DomainObject
// _ = repository.Client.Hash.ToEntity("redisKey", "field", &client)
func (redisHash *redisHash) ToEntity(key string, field string, entity any) error {
sw := stopwatch.StartNew()
jsonContent, err := redisHash.rdb.HGet(ctx, key, field).Result()
if err != nil {
return err
}
flog.Debugf("redisHash.ToEntity:%s", sw.GetMillisecondsText())

// 反序列
return json.Unmarshal([]byte(jsonContent), entity)
}
Expand Down Expand Up @@ -88,20 +84,16 @@ func (redisHash *redisHash) ToArray(key string, arrSlice any) error {
// ToListAny 将hash的数据转成collections.ListAny
func (redisHash *redisHash) ToListAny(key string, itemType reflect.Type) (collections.ListAny, error) {
lst := collections.NewListAny()
sw := stopwatch.StartNew()
result, err := redisHash.rdb.HGetAll(ctx, key).Result()
flog.Debugf("redisHash.ToListAny:%s", sw.GetMillisecondsText())
if err != nil {
flog.Error(err)
return lst, err
}
sw = stopwatch.StartNew()
for _, vJson := range result {
item := reflect.New(itemType).Interface()
_ = json.Unmarshal([]byte(vJson), item)
lst.Add(reflect.ValueOf(item).Elem().Interface())
}
flog.Debugf("redisHash.json.Unmarshal:%s", sw.GetMillisecondsText())
return lst, nil
}

Expand Down

0 comments on commit d22cd6a

Please sign in to comment.