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

The efficiency of Get will decrease if too many Set are executed #168

Open
ivan1218zhang opened this issue Aug 2, 2023 · 1 comment
Open

Comments

@ivan1218zhang
Copy link

It's caused by the RWLock for the thread-safe. How about using sync.Map? It can increase the efficiency of Get.

@ilius
Copy link

ilius commented Aug 2, 2023

I don't think sync.Map would be a good default choice.
Caches are gerenally read more freaquently that written to.

I would suggest sending your cache updates to a channel and recieving from it on a different goroutine in a loop (select with timeout) and updating the cache.

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