开源高性能文件Queue实现BigQueue-Go

jhunters · · 3766 次点击 · 开始浏览    置顶
这是一个创建于 的主题,其中的信息可能已经有所发展或是发生改变。

**BigQueue-Go是由纯golang开发,无任何三方库依赖, 基于本地文件的高性能Queue实现, 同步与异步模式,使用也非常简洁**<br> github地址: [ **https://github.com/jhunters/bigqueue**](https://github.com/jhunters/bigqueue)<br> Feture说明:<br> **Fast **: close to the speed of direct memory access, both enqueue and dequeue are close to O(1) memory access.<br> **Big **: the total size of the queue is only limited by the available disk space.<br> **Persistent **: all data in the queue is persisted on disk, and is crash resistant.<br> **Reliable **: OS will be responsible to presist the produced messages even your process crashes.<br> **Realtime **: messages produced by producer threads will be immediately visible to consumer threads.<br> **Memory-efficient **: automatic paging & swapping algorithm, only most-recently accessed data is kept in memory.<br> **Thread-safe **: multiple threads can concurrently enqueue and dequeue without data corruption.<br> **Simple&Light ** : pure Golang implements without any 3rd-party library<br> 快速开发示例: ```go import "github.com/jhunters/bigqueue" func main() { var queue = new(bigqueue.FileQueue) err := queue.Open(".", "testqueue", nil) if err != nil { fmt.Println(err) return } defer queue.Close() data := []byte("hello jhunters") i, err := queue.Enqueue(data) if err != nil { fmt.Println(err) return } else { fmt.Println("Enqueued index=", i, string(data)) } index, bb, err := queue.Dequeue() if err != nil { fmt.Println(err) return } fmt.Println("Dequeue data:", index, string(bb)) } ``` ![架构图](https://raw.githubusercontent.com/jhunters/bigqueue/master/docs/images/log_collector.png)

有疑问加站长微信联系(非本文作者)

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

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