Skip to content

Build and installation

PAN, Myautsai edited this page Feb 4, 2016 · 2 revisions

For libmc user

You can install from PyPI:

pip install libmc

If you are encountering any issue related to Cython, try to upgrade your Cython and try it again:

pip install --upgrade Cython

If you're using golibmc, you can import golibmc directly. E.g.:

package main

import "fmt"
import "github.com/douban/libmc/golibmc"

func main() {
	servers := []string{
		"localhost:11211",
	}
	key := "foo"
	mc := golibmc.SimpleNew(servers)
	item := golibmc.Item{
		Key:   key,
		Value: []byte("year2016"),
	}
	mc.Set(&item)
	itemGot, _ := mc.Get(key)
	fmt.Println(string(itemGot.Value))
}

For libmc developer

To build the internal C/C++ code solely, you should install cmake first, and then:

mkdir -p build
cd build
cmake ..
make

To run unittest for the internal C/C++ code:

make test

To build the Python module (and the Cython module), you should use python setuptools:

python setup.py build

If you want to build the Cython module in-place:

python setup.py build_ext --inplace

To run unittest for the Cython wrapper:

python misc/generate_hash_dataset.py tests/resources/keys.txt
./misc/memcached_server start
python setup.py test

To build the Golang wrapper:

./misc/memcached_server start
cd golibmc
go build

To run unittest for the Golang wrapper:

./misc/memcached_server start
cd golibmc
go test