<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't this a performance issue? Wouldn't a connection pool be better maybe?</p>
<hr/>**评论:**<br/><br/>robbles: <pre><p>Doesn't look like that code actually accesses the Redis client. It'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's a local cache that gets written to Redis when <code>Release</code> is called?</p></pre>seufert: <pre><p>I don't think it's a performance problem, but it'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't suggest otherwise), the answer is <em>yes</em>, it's fine.</p></pre>daniels0xff: <pre><p>Well, I'm just getting started with Go, so I'm kind of asking all these questions to better understand how things work.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传