Aerospike Go Client

Aerospike Go 客户端。Aerospike 是一种分布式、可扩展的 NoSQL 数据库。「Aerospike Client Go. Aerospike is a distributed, scalable NoSQL database.」

  • 所有者: aerospike/aerospike-client-go
  • 平台: Linux,Mac
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Aerospike Go Client

Aerospike Client Go
Build Status
Godoc

An Aerospike library for Go.

This library is compatible with Go 1.9+ and supports the following operating systems: Linux, Mac OS X (Windows builds are possible, but untested).

Up-to-date documentation is available in the Godoc.

You can refer to the test files for idiomatic use cases.

Please refer to CHANGELOG.md for release notes, or if you encounter breaking changes.

Notice:

We have released the Go Client v2, with some breaking API changes. Most changes are minor, and can be fixed with relative ease.

The only major issue is that the behavior of the client when a key does not exist has changed.

It used to return no error, but a nil Record.Bins. Now it returns ErrKeyNotFound error.

This is a significant changes, and you should search your code for all instances of Bins == nil and adapt the code accordingly.

Please refer to the CHANGELOG.md for details.

Usage:

The following is a very simple example of CRUD operations in an Aerospike database.

package main

import (
  "fmt"

  aero "github.com/aerospike/aerospike-client-go"
)

// This is only for this example.
// Please handle errors properly.
func panicOnError(err error) {
  if err != nil {
    panic(err)
  }
}

func main() {
  // define a client to connect to
  client, err := aero.NewClient("127.0.0.1", 3000)
  panicOnError(err)

  key, err := aero.NewKey("test", "aerospike", "key")
  panicOnError(err)

  // define some bins with data
  bins := aero.BinMap{
    "bin1": 42,
    "bin2": "An elephant is a mouse with an operating system",
    "bin3": []interface{}{"Go", 2009},
  }

  // write the bins
  err = client.Put(nil, key, bins)
  panicOnError(err)

  // read it back!
  rec, err := client.Get(nil, key)
  panicOnError(err)

  // delete the key, and check if key exists
  existed, err := client.Delete(nil, key)
  panicOnError(err)
  fmt.Printf("Record existed before delete? %v\n", existed)
}

More examples illustrating the use of the API are located in the
examples directory.

Details about the API are available in the docs directory.

Prerequisites

Go version v1.9+ is required.

To install the latest stable version of Go, visit
http://golang.org/dl/

Aerospike Go client implements the wire protocol, and does not depend on the C client.
It is goroutine friendly, and works asynchronously.

Supported operating systems:

  • Major Linux distributions (Ubuntu, Debian, Red Hat)
  • Mac OS X
  • Windows (untested)

Installation:

  1. Install Go 1.9+ and setup your environment as Documented here.
  2. Get the client in your GOPATH : go get github.com/aerospike/aerospike-client-go
  • To update the client library: go get -u github.com/aerospike/aerospike-client-go

Using gopkg.in is also supported: go get -u gopkg.in/aerospike/aerospike-client-go.v1

Some Hints:

  • To run a go program directly: go run <filename.go>
  • to build: go build -o <output> <filename.go>
  • example: go build -o benchmark tools/benchmark/benchmark.go

Performance Tweaking

We are bending all efforts to improve the client's performance. In our reference benchmarks, Go client performs almost as good as the C client.

To read about performance variables, please refer to docs/performance.md

Tests

This library is packaged with a number of tests. Tests require Ginkgo and Gomega library.

Before running the tests, you need to update the dependencies:

$ go get .

To run all the test cases with race detection:

$ ginkgo -r -race

Examples

A variety of example applications are provided in the examples directory.

Tools

A variety of clones of original tools are provided in the tools directory.
They show how to use more advanced features of the library to re-implement the same functionality in a more concise way.

Benchmarks

Benchmark utility is provided in the tools/benchmark directory.
See the tools/benchmark/README.md for details.

API Documentation

A simple API documentation is available in the docs directory. The latest up-to-date docs can be found in Godoc.

Google App Engine

To build the library for App Engine, build it with the build tag app_engine. Aggregation functionality is not available in this build.

Reflection, and Object API

To make the library both flexible and fast, we had to integrate the reflection API (methods with [Get/Put/...]Object names) tightly in the library. In case you wanted to avoid mixing those API in your app inadvertently, you can use the build tag as_performance to remove those APIs from the build.

License

The Aerospike Go Client is made available under the terms of the Apache License, Version 2, as stated in the file LICENSE.

Individual files may be made available under their own specific license,
all compatible with Apache License, Version 2. Please see individual files for details.

主要指标

概览
名称与所有者aerospike/aerospike-client-go
主编程语言Go
编程语言Shell (语言数: 2)
平台
许可证Apache License 2.0
所有者活动
创建于2014-07-26 02:56:21
推送于2025-04-19 00:19:57
最后一次提交2023-07-10 16:47:39
发布数164
最新版本名称v8.2.1 (发布于 )
第一版名称1.0.0 (发布于 2014-08-12 14:46:22)
用户参与
星数447
关注者数73
派生数206
提交数1.6k
已启用问题?
问题数323
打开的问题数29
拉请求数98
打开的拉请求数7
关闭的拉请求数53
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?