sm
/
cache
1
0
Fork 0

revised formatting

This commit is contained in:
Giuseppe 2015-12-05 14:53:44 +01:00
parent 3969366c62
commit 05f1124e1e
2 changed files with 3 additions and 12 deletions

View File

@ -11,7 +11,6 @@ import (
"time"
)
type Item struct {
Object interface{}
Expiration int64
@ -26,7 +25,6 @@ func (node Node) Less(than llrb.Item) bool {
return node.Expiration < than.(Node).Expiration
}
// Returns true if the item has expired.
func (item Item) Expired() bool {
if item.Expiration == 0 {
@ -907,14 +905,11 @@ func (c *cache) delete(k string) (interface{}, bool) {
c.deleteFromBst(Node{Expiration: v.Expiration, Key: k})
if c.onEvicted != nil {
return v.Object, true
} else {
return nil, false
}
}
return nil, false
}
type keyAndValue struct {
key string
value interface{}
@ -948,8 +943,6 @@ func (c *cache) DeleteExpired() {
}
}
// Sets an (optional) function that is called with the key and value when an
// item is evicted from the cache. (Including when it is deleted manually, but
// not when it is overwritten.) Set to nil to disable.
@ -1015,10 +1008,8 @@ func (c *cache) Load(r io.Reader) error {
c.items[k] = v
if !found {
c.sortedItems.InsertNoReplace(Node{Expiration: v.Expiration, Key: k})
}
}
}
}
}
}
return err

View File

@ -173,7 +173,7 @@ func newShardedCache(n int, de time.Duration) *shardedCache {
c := &cache{
defaultExpiration: de,
items: map[string]Item{},
sortedItems: llrb.New(),
sortedItems: llrb.New(),
}
sc.cs[i] = c
}