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 d22cd6a commit df5fe0c
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions cacheInRedis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/farseer-go/cache"
"github.com/farseer-go/collections"
"github.com/farseer-go/fs/flog"
"github.com/farseer-go/fs/stopwatch"
"reflect"
)

Expand All @@ -14,9 +13,6 @@ type cacheInRedis struct {
}

func (r cacheInRedis) Get(cacheKey cache.CacheKey) collections.ListAny {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.Get:%s", sw.GetMillisecondsText()) }()

// 从redis hash中读取到slice
redisClient := NewClient(cacheKey.RedisConfigName)
lst, err := redisClient.Hash.ToListAny(cacheKey.Key, cacheKey.ItemType)
Expand All @@ -27,9 +23,6 @@ func (r cacheInRedis) Get(cacheKey cache.CacheKey) collections.ListAny {
}

func (r cacheInRedis) GetItem(cacheKey cache.CacheKey, cacheId string) any {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.GetItem:%s", sw.GetMillisecondsText()) }()

// 动态创建实体
entityPtr := reflect.New(cacheKey.ItemType).Interface()

Expand All @@ -46,8 +39,9 @@ func (r cacheInRedis) GetItem(cacheKey cache.CacheKey, cacheId string) any {
}

func (r cacheInRedis) Set(cacheKey cache.CacheKey, val collections.ListAny) {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.Set:%s", sw.GetMillisecondsText()) }()
if val.Count() == 0 {
return
}

// 将ListAny转成map
values := make(map[string]any)
Expand All @@ -68,9 +62,6 @@ func (r cacheInRedis) Set(cacheKey cache.CacheKey, val collections.ListAny) {
}

func (r cacheInRedis) SaveItem(cacheKey cache.CacheKey, newVal any) {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.SaveItem:%s", sw.GetMillisecondsText()) }()

redisClient := NewClient(cacheKey.RedisConfigName)
newValDataKey := cacheKey.GetUniqueId(newVal)
err := redisClient.Hash.SetEntity(cacheKey.Key, newValDataKey, newVal)
Expand All @@ -80,9 +71,6 @@ func (r cacheInRedis) SaveItem(cacheKey cache.CacheKey, newVal any) {
}

func (r cacheInRedis) Remove(cacheKey cache.CacheKey, cacheId string) {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.Remove:%s", sw.GetMillisecondsText()) }()

redisClient := NewClient(cacheKey.RedisConfigName)
_, err := redisClient.Hash.Del(cacheKey.Key, cacheId)
if err != nil {
Expand All @@ -91,9 +79,6 @@ func (r cacheInRedis) Remove(cacheKey cache.CacheKey, cacheId string) {
}

func (r cacheInRedis) Clear(cacheKey cache.CacheKey) {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.Clear:%s", sw.GetMillisecondsText()) }()

redisClient := NewClient(cacheKey.RedisConfigName)
_, err := redisClient.Key.Del(cacheKey.Key)
if err != nil {
Expand All @@ -102,17 +87,11 @@ func (r cacheInRedis) Clear(cacheKey cache.CacheKey) {
}

func (r cacheInRedis) Count(cacheKey cache.CacheKey) int {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.Count:%s", sw.GetMillisecondsText()) }()

redisClient := NewClient(cacheKey.RedisConfigName)
return redisClient.Hash.Count(cacheKey.Key)
}

func (r cacheInRedis) ExistsItem(cacheKey cache.CacheKey, cacheId string) bool {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.ExistsItem:%s", sw.GetMillisecondsText()) }()

redisClient := NewClient(cacheKey.RedisConfigName)
exists, err := redisClient.Hash.Exists(cacheKey.Key, cacheId)
if err != nil {
Expand All @@ -122,9 +101,6 @@ func (r cacheInRedis) ExistsItem(cacheKey cache.CacheKey, cacheId string) bool {
}

func (r cacheInRedis) ExistsKey(cacheKey cache.CacheKey) bool {
sw := stopwatch.StartNew()
defer func() { flog.Debugf("cacheInRedis.ExistsKey:%s", sw.GetMillisecondsText()) }()

redisClient := NewClient(cacheKey.RedisConfigName)
exists, err := redisClient.Key.Exists(cacheKey.Key)
if err != nil {
Expand Down

0 comments on commit df5fe0c

Please sign in to comment.