comment log in cache.
This commit is contained in:
parent
54c5905a58
commit
5b95c1a2f4
8
code/tool/cache/cache.go
vendored
8
code/tool/cache/cache.go
vendored
@ -201,7 +201,7 @@ func (table *Table) Add(key interface{}, duration time.Duration, data interface{
|
|||||||
item := NewItem(key, duration, data)
|
item := NewItem(key, duration, data)
|
||||||
|
|
||||||
table.Lock()
|
table.Lock()
|
||||||
table.log("Adding item with key %v and lifespan of %v to table", key, duration)
|
table.log("Adding item with key %v and lifespan of %d to table", key, duration)
|
||||||
table.items[key] = item
|
table.items[key] = item
|
||||||
|
|
||||||
expDur := table.cleanupInterval
|
expDur := table.cleanupInterval
|
||||||
@ -243,7 +243,7 @@ func (table *Table) Delete(key interface{}) (*Item, error) {
|
|||||||
|
|
||||||
table.Lock()
|
table.Lock()
|
||||||
defer table.Unlock()
|
defer table.Unlock()
|
||||||
table.log("Deleting item with key %v created on %v and hit %v times from table", key, r.createTime, r.count)
|
table.log("Deleting item with key %v created on %s and hit %d times from table", key, r.createTime, r.count)
|
||||||
delete(table.items, key)
|
delete(table.items, key)
|
||||||
|
|
||||||
return r, nil
|
return r, nil
|
||||||
@ -268,7 +268,7 @@ func (table *Table) NotFoundAdd(key interface{}, lifeSpan time.Duration, data in
|
|||||||
}
|
}
|
||||||
|
|
||||||
item := NewItem(key, lifeSpan, data)
|
item := NewItem(key, lifeSpan, data)
|
||||||
table.log("Adding item with key %v and lifespan of %v to table", key, lifeSpan)
|
table.log("Adding item with key %v and lifespan of %d to table", key, lifeSpan)
|
||||||
table.items[key] = item
|
table.items[key] = item
|
||||||
|
|
||||||
expDur := table.cleanupInterval
|
expDur := table.cleanupInterval
|
||||||
@ -368,7 +368,7 @@ func (table *Table) MostAccessed(count int64) []*Item {
|
|||||||
|
|
||||||
// print log.
|
// print log.
|
||||||
func (table *Table) log(format string, v ...interface{}) {
|
func (table *Table) log(format string, v ...interface{}) {
|
||||||
fmt.Printf(format, v)
|
//fmt.Printf(format+"\r\n", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTable() *Table {
|
func NewTable() *Table {
|
||||||
|
Loading…
Reference in New Issue
Block a user