karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.28k stars 119 forks source link

Cache can't be garbage collected #3

Open ebonetti opened 9 years ago

ebonetti commented 9 years ago

Goroutine (associated with cache worker) prevent cache from being collected. In my opinion there should be a way to stop it. Alternatively, this fact should be documented.

Keep up the good work, Enrico

karlseguin commented 9 years ago

Are you ok with the cache being unusable once Stop is called? Is panic'ing a little extreme or acceptable?

Consider: https://github.com/karlseguin/ccache/commit/bfa769c6b6c794afa640d7259ebc270c7da037a7

ebonetti commented 9 years ago

Edited: there is a big problem with "deletables" channel: goroutines waiting to pass values are blocked.. In "worker", just before exiting goroutine, the Cache should be cleared (enforcing user to stop using it) and then close "deletables". This way it panics on both channel on a send attempt, but in my opinion panicking isn't right.. Enrico