Skip to content

Commit

Permalink
del log
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-uxuy committed Jan 16, 2024
1 parent 5d04c80 commit 4d3f72f
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions cache_store/cache_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cache_store

import (
"fmt"
"github.com/uxuycom/indexer/xylog"
"sync"
"time"
)
Expand All @@ -27,22 +26,19 @@ type CacheItem struct {
func (m *CacheStore) Set(key string, value interface{}) {
useMemory := m.cacheMemory + int64(len(fmt.Sprintf("%v", key))) + int64(len(fmt.Sprintf("%v", value)))
if useMemory > m.maxCapacity {
xylog.Logger.Infof("the set maximum memory is exceeded. maxCapacity:%v, cacheMemory:%v\n", m.maxCapacity, m.cacheMemory)
return
}

duration := time.Second * time.Duration(m.duration)
expiration := time.Now().Add(duration).UnixNano()
item := CacheItem{Value: value, Expiration: expiration}
xylog.Logger.Info("value", value)
m.data.Store(key, item)
m.cacheMemory = useMemory
}

func (m *CacheStore) Get(key string) (interface{}, bool) {
item, ok := m.data.Load(key)
if !ok {
xylog.Logger.Infof("not using the cache. key:%s", key)
return nil, false
}

Expand Down

0 comments on commit 4d3f72f

Please sign in to comment.