Go language wrapper for Tokyo Tyrant
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
AUTHORS
LICENSE
Makefile
README.mdown
connect.go
startserver.sh
ttwrapper.c
ttwrapper.h
tyrant.go

README.mdown

gotyrant

gotyrant is a wrapper around the Tokyo Tyrant network interface library for Tokyo Cabinet for the Go language.

It's very incomplete at this point. It only does what I've needed so far for an application I'm working on. I'll flush it out as the app progresses and I learn the go language better, but I thought it might be useful to some other users.

It's also very probable that the go API will change drastically...

Getting the source

Get it from github:

git clone git://github.com/patrickxb/gotyrant.git

Building and Installing

You need to have go installed and have the GOROOT, GOARCH, GOOS, and GOBIN environment variables set.

After that, just do:

make
make install

Usage

Here's some sample code (also located in connect.go in the source distribution):

package main

import (
	"tyrant";
	"fmt";
	"os";
)

func main() {
	fmt.Printf("trying to use tyrant package to connect to tokyo tyrant\n");
	connection, ok := tyrant.Connect();
	if !ok {
		fmt.Printf("no connection...\n");
		os.Exit(1);
	}

	columns := make(map[string]string);
	columns["name"] = "falcon";
	columns["age"] = "31";
	columns["lang"] = "ja";
	if connection.Put("12345", columns) {
		fmt.Printf("put ok\n")
	} else {
		fmt.Printf("put failed\n")
	}

	query := connection.MakeQuery();
	query.AddCondition("name", tyrant.StringBeginsWith(), "f");
	result := connection.Execute(query);
	fmt.Printf("%d rows returned\n", len(result.Rows));
	for index, row := range result.Rows {
		fmt.Printf("ROW %d ------------------\n", index);
		for name, value := range row.Data {
			fmt.Printf("%s => %s\n", name, value)
		}
		fmt.Printf("\n");
	}

	fmt.Printf("done\n");
}

Contact

Please let me know if you're using this library and if you have any questions or comments. You can contact me through github (username = patrickxb), or you can figure out my email address based on my first name (patrick) and my company (xblabs.com).