From 05f1124e1e0e66917eb3eec6a91b69db66a16049 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Sat, 5 Dec 2015 14:53:44 +0100 Subject: [PATCH] revised formatting --- cache.go | 13 ++----------- sharded.go | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cache.go b/cache.go index 4da5092..51afcb1 100644 --- a/cache.go +++ b/cache.go @@ -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 diff --git a/sharded.go b/sharded.go index be5ab6d..e69e980 100644 --- a/sharded.go +++ b/sharded.go @@ -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 }