sm
/
cache
1
0
Fork 0

gofmt and redundant 'if it was enabled'

This commit is contained in:
Patrick Mylund Nielsen 2012-01-02 14:11:17 +01:00
parent ac5b195364
commit ca7e0d4f78
2 changed files with 13 additions and 15 deletions

View File

@ -235,7 +235,6 @@ func (c *cache) Decrement(k string, n int64) error {
return c.Increment(k, n*-1)
}
// Deletes an item from the cache. Does nothing if the item does not exist in the cache.
func (c *cache) Delete(k string) {
c.mu.Lock()
@ -272,7 +271,6 @@ func (i *Item) Expired() bool {
return i.Expiration.Before(time.Now())
}
func (j *janitor) Run(c *cache) {
j.stop = make(chan bool)
tick := time.Tick(j.Interval)
@ -316,9 +314,9 @@ func New(de, ci time.Duration) *Cache {
go j.Run(c)
}
// This trick ensures that the janitor goroutine (which--granted it was enabled--is
// running DeleteExpired on c forever, if it was enabled) does not keep the returned C
// object from being garbage collected. When it is garbage collected, the finalizer stops
// the janitor goroutine, after which c is collected.
// running DeleteExpired on c forever) does not keep the returned C object from being
// garbage collected. When it is garbage collected, the finalizer stops the janitor
// goroutine, after which c is collected.
C := &Cache{c}
if ci > 0 {
runtime.SetFinalizer(C, stopJanitor)