bluele / gcache

An in-memory cache library for golang. It supports multiple eviction policies: LRU, LFU, ARC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can getValue use RLock?

Cyufei87 opened this issue · comments

c.mu.Lock()

can here use RLock to decrease lock race?

sort of...getValue() checks if the item has expired, and deletes it if it has. So you'd have to convert the reader lock to a full lock.

Also the cache engine supports a loaderFunc that will attempt to generate a value if it's not found in the cache. That would also require a real Lock.