项目作者: gyuzeh

项目描述 :
In Memory Database for Go
高级语言: Go
项目地址: git://github.com/gyuzeh/in-memdb.git
创建时间: 2020-11-22T20:41:26Z
项目社区:https://github.com/gyuzeh/in-memdb

开源协议:MIT License

下载


In Memory Database

Golang InMemory Database allows to abstract from your database implementation to help you in development by replacing the atual database with a stubbed.

Quickstart

  1. go get github.com/gyuzeh/in-memdb
  1. import "github.com/gyuzeh/in-memdb/pkg/serialization"
  2. import "github.com/gyuzeh/in-memdb/pkg/inmemdb"
  3. func InMemDbExample() {
  4. key := "12355634"
  5. data := Product{
  6. ID: 12355634,
  7. Name: "Shirt",
  8. Description: "This is my shirt and I love it! Buy me",
  9. Price: 300.2,
  10. Colors: []string{"red", "yello", "blue"},
  11. Size: []string{"S", "M", "L"},
  12. }
  13. memdb := inmemdb.New(serialization.PlainSerialization{})
  14. memdb.Set(key, data)
  15. memdb.Get(key, data)
  16. memdb.Delete(key)
  17. }

Available Serialization for InMemory Db

  1. memdb := inmemdb.New(serialization.PlainSerialization{}) // plain objects in memory
  2. memdb := inmemdb.New(serialization.MsgPackSerialization{}) // serializes to MsgPack in Memory
  3. memdb := inmemdb.New(serialization.GobSerialization{}) // serializes to Gob in Memory

Building

  1. make build

Running the tests

  1. make unit-test

Running benchmark tests

  1. make benchmark-test