Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

func (cache *Cache) startExpirationProcessing() - Never Exits and Leaves residual Goroutines. #23

Closed
zveinn opened this issue Oct 2, 2019 · 8 comments

Comments

@zveinn
Copy link

zveinn commented Oct 2, 2019

Hey, I noticed there is no exit case in your Goroutine here:
https://github.com/ReneKroon/ttlcache/blob/49e7d8e56413a8ee1f826b064e7268f6e10ca2d3/cache.go#L52

I was developing an application that start multiple caches as child-struct. But when the parent is removed this function - func (cache *Cache) startExpirationProcessing() - keeps running forever.

Do you perhaps have a way of killing it somewhere in your code ? I like your package and I would love to keep using it, but in the current state I can not :(

@zveinn zveinn changed the title func (cache *Cache) startExpirationProcessing() - Never Exits and Leaves possible residual Goroutines. func (cache *Cache) startExpirationProcessing() - Never Exits and Leaves residual Goroutines. Oct 2, 2019
@ReneKroon
Copy link
Contributor

ReneKroon commented Oct 4, 2019

Good call, i'll fix it in the upcoming 2 weeks i think.

I guess adding a Close method would work?

@zveinn
Copy link
Author

zveinn commented Oct 4, 2019

Yep, that should do it!

However, maybe "close" is not the right description. Somehow close feels like a non-permanent move. Maybe it's just me ?

Since you already have:
NewChache()

Maybe one of these two:
DeleteCache()
RemoveCache()

@zveinn
Copy link
Author

zveinn commented Oct 5, 2019

Actually, now that I think about it. Do you feel like getting some help on the package ?

I would not mind implementing a fix for you. I can make some adjustments and then deliver them in PR's.

@ReneKroon
Copy link
Contributor

A pull request is always welcome. i think 'RemoveCache' is a good name but i also like to check if we can use some common standard interface. For example, Closer reads:

type Closer
Closer is the interface that wraps the basic Close method.

The behavior of Close after the first call is undefined. Specific implementations may document their own behavior.

type Closer interface {
    Close() error
}

But in this case i'm happy with either solution.

@zveinn
Copy link
Author

zveinn commented Oct 9, 2019

Yep, that makes perfect sense. I will take a look this week and see if I can't get this done :)

@ReneKroon
Copy link
Contributor

@zkynet Can you test this code? Its merged to master but not an official release yet.

@zveinn
Copy link
Author

zveinn commented Oct 13, 2019

Sweet, I was about to get my hand dirty tonight, but since you already did I'll do a testing session in stead. It'll happen in about 6-7 hours.

Good job.

@zveinn
Copy link
Author

zveinn commented Oct 15, 2019

Completely forgot to report back!

It seems that did it. Thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants