Abstraction package built on top of BoltDB key/value store, would love some opinions on it.

blov · · 490 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi Gophers,</p> <p>I use key/value storage allot through out my code and the excellent <a href="https://github.com/boltdb/bolt" rel="nofollow">BoltDB</a> is great for this. </p> <p>I have built my own package that abstracts some of the complexities in BoltDB, so you can do simple Gets and Puts and don&#39;t have to worry about starting the database or using transactions safely: <a href="https://github.com/Charlesworth/byteStore" rel="nofollow">byteStore</a></p> <p>The trade off is that you don&#39;t get as fine grained control, but its meant to make plugging some persistent key/value storage into your project very simple and easy to reason about.</p> <p>I&#39;d love to get peoples opinions on the project on how to improve with new features or improve current code.</p> <p>tl;dr: I&#39;ve made an easy to use, persistent key/value store package that sits on top of BoltDB, would love some opinions on it: <a href="https://github.com/Charlesworth/byteStore" rel="nofollow">byteStore</a></p> <p>Update: Thanks for the feedback everyone, I have re-written most of the package in response to these constructive comments.</p> <hr/>**评论:**<br/><br/>Queue29: <pre><p>You&#39;ve taken an abstractable implementation and turned it into private global variables, and hard-coded the database path to whatever directory the program is launched from. Although this package is great for throw away scripts and whatnot, no reasonable engineer would use something like this in a testable, configurable program. Also I&#39;m not sure what purpose the global mutex is supposed to serve; you&#39;re using transactions for everything anyway. </p></pre>ecmdome: <pre><p>I&#39;m going to look at this at home. I&#39;ve done similar things in my own projects </p></pre>djherbis: <pre><p>There&#39;s been two libraries that do this (plus a little more) posted here in the past week or so. Perhaps you can check them out to get some insight, or just use one of them:</p> <p><a href="https://github.com/djherbis/stow" rel="nofollow">https://github.com/djherbis/stow</a></p> <p><a href="https://github.com/omeid/thunder" rel="nofollow">https://github.com/omeid/thunder</a></p></pre>albatr0s: <pre><blockquote> <p>exiting your Go program without Close is safe as long as there are no currently running writing functions, as this could corrupt the .db file with a unfinished transaction.</p> </blockquote> <p>This is false, and one of the most important features of Bolt <strong>is</strong> this being false.</p></pre>albatr0s: <pre><p>Using a mutex, particularly for read operations negates another important feature of Bolt: multiple concurrent reads.</p></pre>

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

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