Skip to content

Commit

Permalink
BUGFIXED: while lrucache destroy goroutine exit
Browse files Browse the repository at this point in the history
  • Loading branch information
王瑞明 committed Aug 10, 2018
1 parent dbec49a commit 50c2e1f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lrucache.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ func NewLruCache(name string, config ...string) *LruCache {
cache.chCacheExit = make(chan bool)
cache.waitGroup.Add(1)
go cache.shrinkCache()
logger.Info("LruCache create ok. name:%s, low:%d(byte), high:%d(byte),interval:%d(s)",
cache.name, cache.low, cache.high, cache.interval)
logger.Info(`LruCache create with configure:
--------------------------
| name:"%s"
| low:%dbyte=%.3fMb
| high:%dbyte=%.3fMb
| interval:%d(s)
--------------------------`,
cache.name, cache.low, float64(cache.low)/1024/1024,
cache.high, float64(cache.high)/1024/1024, cache.interval)
return cache
}

Expand All @@ -59,10 +66,10 @@ func (this *LruCache) Destroy() {
this.Lock()
if this.chCacheExit != nil {
close(this.chCacheExit)
this.waitGroup.Wait()
this.chCacheExit = nil
}
this.Unlock()
this.waitGroup.Wait()
}
this = nil
}
Expand Down Expand Up @@ -341,3 +348,8 @@ func (this *LruCache) shrinkCache() {
}
}
}

// 获取缓存名称
func (this *LruCache) GetCacheName() string {
return this.name
}

0 comments on commit 50c2e1f

Please sign in to comment.