muesli / cache2go

Concurrency-safe Go caching library with expiration capabilities and access counters
Other
2.11k stars 516 forks source link

question about go use #10

Closed sunxiao2010n closed 7 years ago

sunxiao2010n commented 7 years ago

In file cache.go

if !ok { t = &CacheTable{ name: table, items: make(map[interface{}]*CacheItem), }

  mutex.Lock()
  cache[table] = t
  mutex.Unlock()

}

return t

the assigment function of cache item is

  t = &CacheTable{ ... }

The "t = &CacheTable" seems to be stored at stack , and can not be reentrant after function returns. How could I understand this ? Thanks.

sunxiao2010n commented 7 years ago

t = &CacheTable means t = new CacheTable