#ledis包使用
基于 ubuntu 14.04
###安装依赖包 sudo apt-get install build-essential automake libtool pkg-config
###下载go项目 go get github.com/siddontang/ledisdb go get github.com/siddontang/goleveldb go get github.com/siddontang/go-log/log go get github.com/siddontang/go-snappy/snappy
###安装snappy leveldb ledisdb提供脚本,安装 leveldb,snappy 很简单
cd $GOPATH/src/github.com/siddontang/ledisdb/
sudo sh build_tool/build_leveldb.sh
###编辑 main.go package main
import (
"fmt"
"github.com/siddontang/ledisdb/config"
"github.com/siddontang/ledisdb/ledis"
)
func main() {
cfg := new(config.Config)
cfg.DataDir = "/tmp/testdb"
l, _ := ledis.Open(cfg)
db, _ := l.Select(0)
key := []byte("aaa")
value := []byte("ccc")
db.Set(key, value)
res, _ := db.Get(key)
fmt.Println(string(res))
}
输出:ccc