Replace time.Now().Sub with time.Since
This commit is contained in:
4
client/cache/memory.go
vendored
4
client/cache/memory.go
vendored
@@ -42,7 +42,7 @@ func (mi *MemoryItem) isExpire() bool {
|
||||
if mi.lifespan == 0 {
|
||||
return false
|
||||
}
|
||||
return time.Now().Sub(mi.createdTime) > mi.lifespan
|
||||
return time.Since(mi.createdTime) > mi.lifespan
|
||||
}
|
||||
|
||||
// MemoryCache is a memory cache adapter.
|
||||
@@ -66,7 +66,7 @@ func (bc *MemoryCache) Get(ctx context.Context, key string) (interface{}, error)
|
||||
bc.RLock()
|
||||
defer bc.RUnlock()
|
||||
if itm, ok :=
|
||||
bc.items[key]; ok {
|
||||
bc.items[key]; ok {
|
||||
if itm.isExpire() {
|
||||
return nil, ErrKeyExpired
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (builder *FilterChainBuilder) report(ctx context.Context, inv *orm.Invocati
|
||||
}
|
||||
|
||||
func (builder *FilterChainBuilder) reportTxn(ctx context.Context, inv *orm.Invocation) {
|
||||
dur := time.Now().Sub(inv.TxStartTime) / time.Millisecond
|
||||
dur := time.Since(inv.TxStartTime) / time.Millisecond
|
||||
summaryVec.WithLabelValues(inv.Method, inv.TxName,
|
||||
strconv.FormatBool(inv.InsideTx), inv.TxName).Observe(float64(dur))
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func NewLog(out io.Writer) *Log {
|
||||
|
||||
func debugLogQueies(alias *alias, operaton, query string, t time.Time, err error, args ...interface{}) {
|
||||
var logMap = make(map[string]interface{})
|
||||
sub := time.Now().Sub(t) / 1e5
|
||||
sub := time.Since(t) / 1e5
|
||||
elsp := float64(int(sub)) / 10.0
|
||||
logMap["cost_time"] = elsp
|
||||
flag := " OK"
|
||||
|
||||
Reference in New Issue
Block a user