<p>Hi Guys,</p>
<p>I'm looking for a tiny cache library. Basically I need storage some keys (without a lot complexity) I comes across with this project[1] but I would like to know if other folks can suggest a new ones different based on their own experience.</p>
<p>(I know I can write a new library, but I don't need reinventing the wheel)</p>
<p>[1] <a href="https://github.com/patrickmn/go-cache">https://github.com/patrickmn/go-cache</a> </p>
<hr/>**评论:**<br/><br/>dgryski: <pre><p>All caching algorithms have different tradeoffs in terms of speed and expiration accuracy. Your post doesn't give enough details on your workloads. Depending on the recomputation cost, even something like random eviction can be sufficient and has the advantage of a very simple implementation: <a href="https://github.com/dgryski/trifles/blob/master/cachetest/random/random.go">https://github.com/dgryski/trifles/blob/master/cachetest/random/random.go</a> .</p></pre>deivinsontejeda: <pre><p>Sure, I wasn't enough clear about what it's my current case.</p>
<p>I have a microservice which focus on serving files. These file live in different provider (AWS, Azure and so on) I want to avoid hit everytime AWS or Azure for the same object (these objects are Pre-Signed URL). </p>
<p>It's very simple just fetch first time the URL and sub-secuent request return cached data instead of hit external API.</p></pre>dgryski: <pre><p>So how effective does your cache hit ratio need to be? How expensive is a cache miss? Can you just store all the queries? How big is the working set compared to what you can store and how big the total collection is?</p>
<p>My suggestion is still to start with something dumb and measure the effectiveness. Bonus points if you have a query trace you can use to simulate different caches with to see which one matches best. (But really, anything above a simple LRU is just small incremental improvements in cache hit ratio.</p></pre>deivinsontejeda: <pre><p>Awesome, thanks!</p></pre>deivinsontejeda: <pre><p>I ended up writting a little interface using code share and tracking some info in order to get much more details about what exactly I need build. </p>
<p>This is like you suggested to me: a dumb implementation and tuning it given data analyze.</p></pre>seankhliao: <pre><p>What's wrong with a simple map?</p></pre>konart: <pre><p>More like sync.Map, I guess.</p>
<p>Anyway - you'd have to write all the logic by your self. How big can your cache grow, how to clean it etc.</p></pre>albatr0s: <pre><p><a href="https://github.com/golang/groupcache" rel="nofollow">https://github.com/golang/groupcache</a></p>
<p><a href="https://github.com/coocood/freecache" rel="nofollow">https://github.com/coocood/freecache</a></p></pre>NovaX: <pre><p><a href="https://github.com/goburrow/cache" rel="nofollow">https://github.com/goburrow/cache</a></p></pre>dametsumari: <pre><p>I have been happy with <a href="https://github.com/bluele/gcache" rel="nofollow">https://github.com/bluele/gcache</a> - although am considering writing my own, as I dislike interface{} using interfaces as they potentially break if and when I fumble wrong types around :-p</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传