eko / gocache

☔️ A complete Go cache library that brings you multiple ways of managing your caches
https://vincent.composieux.fr/article/i-wrote-gocache-a-complete-and-extensible-go-cache-library/
MIT License
2.4k stars 193 forks source link

Is it possible to set an option during NewLoadable or Get to ensure that when there is no value, it directly performs a synchronous set instead of an asynchronous set? #229

Closed MrHuangjiacong closed 4 months ago

MrHuangjiacong commented 9 months ago

I have a scenario where I make requests to other APIs, and I need to ensure that a particular API is only executed once and its result is saved, especially in high-concurrency situations. Therefore, I require a real-time set operation.

eko commented 4 months ago

Hi,

This issue has been solved by using the singleflight Go tool here: https://github.com/eko/gocache/pull/243

Closing this issue for now but feel free to reopen if any issue remains.

Thank you