Is this ok for performance?

polaris · · 607 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I was just looking at GoMacaron framework which seems nice and noticed the following in the Redis session module <a href="https://github.com/go-macaron/session/blob/master/redis/redis.go#L62" rel="nofollow">https://github.com/go-macaron/session/blob/master/redis/redis.go#L62</a></p> <p>They seem to be using locks for redis client. Is this ok? Isn&#39;t this a performance issue? Wouldn&#39;t a connection pool be better maybe?</p> <hr/>**评论:**<br/><br/>robbles: <pre><p>Doesn&#39;t look like that code actually accesses the Redis client. It&#39;s protecting access to a map.</p> <p>Perhaps this is a default memory-safe stub for testing?</p></pre>Akkifokkusu: <pre><p>Looks like it&#39;s a local cache that gets written to Redis when <code>Release</code> is called?</p></pre>seufert: <pre><p>I don&#39;t think it&#39;s a performance problem, but it&#39;s not necessary: At least the documentation of the redis client used claims to be thread safe and also uses a connection pool.</p></pre>pcj2bs: <pre><p>The <code>defer</code> also has nontrivial overhead.</p></pre>seufert: <pre><p>So you have measured how it performs against a Redis Round-Trip?</p></pre>Consuelas-Revenge: <pre><blockquote> <p>Is this ok for performance?</p> </blockquote> <p>Since you need to ask (i.e. your benchmarks and testing didn&#39;t suggest otherwise), the answer is <em>yes</em>, it&#39;s fine.</p></pre>daniels0xff: <pre><p>Well, I&#39;m just getting started with Go, so I&#39;m kind of asking all these questions to better understand how things work.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

607 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传