From dc5c2d90959c4efe19e36a6d57a200fac40a3ded Mon Sep 17 00:00:00 2001 From: siddontang Date: Sat, 26 Jul 2014 09:22:09 +0800 Subject: [PATCH] update make --- .gitignore | 3 ++- Makefile | 6 ++++++ README.md | 28 +++++++++++++++++----------- bootstrap.sh | 0 build_config.sh | 16 ++++++++++++++++ dev.sh | 26 ++++++++++++++------------ etc/ledis.json | 3 +++ 7 files changed, 58 insertions(+), 24 deletions(-) mode change 100644 => 100755 bootstrap.sh create mode 100755 build_config.sh diff --git a/.gitignore b/.gitignore index d1c3459..49a172d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build *.pyc .DS_Store -nohup.out \ No newline at end of file +nohup.out +build_config.mk \ No newline at end of file diff --git a/Makefile b/Makefile index cdf55bc..e953efe 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,9 @@ +$(shell ./bootstrap.sh) + +$(shell ./build_config.sh build_config.mk ./) + +include build_config.mk + all: build build: diff --git a/README.md b/README.md index 96aacb5..c188dc7 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ # LedisDB -Ledisdb is a high performance NoSQL like Redis based on LevelDB written by go. It supports some advanced data structure like kv, list, hash and zset, and may be alternative for Redis. +Ledisdb is a high performance NoSQL like Redis written by go. It supports some advanced data structure like kv, list, hash and zset, and may be alternative for Redis. + +LedisDB now supports multi database as backend to store data, you can test and choose the proper one for you. ## Features + Rich advanced data structure: KV, List, Hash, ZSet, Bit. -+ Uses leveldb to store lots of data, over the memory limit. ++ Stores lots of data, over the memory limit. ++ Various backend database to use: LevelDB, goleveldb, LMDB. + Supports expiration and ttl. + Redis clients, like redis-cli, are supported directly. + Multi client API supports, including Golang, Python, Lua(Openresty). @@ -15,13 +18,17 @@ Ledisdb is a high performance NoSQL like Redis based on LevelDB written by go. I ## Build and Install -+ Create a workspace and checkout ledisdb source +Create a workspace and checkout ledisdb source - mkdir $WORKSPACE - cd $WORKSPACE - git clone git@github.com:siddontang/ledisdb.git src/github.com/siddontang/ledisdb + mkdir $WORKSPACE + cd $WORKSPACE + git clone git@github.com:siddontang/ledisdb.git src/github.com/siddontang/ledisdb - cd src/github.com/siddontang/ledisdb + cd src/github.com/siddontang/ledisdb + + make + +## LevelDB support + Install leveldb and snappy, if you have installed, skip. @@ -35,12 +42,11 @@ Ledisdb is a high performance NoSQL like Redis based on LevelDB written by go. I + Set LEVELDB_DIR and SNAPPY_DIR to the actual install path in dev.sh. -+ Then: ++ make - . ./bootstap.sh - . ./dev.sh +## RocksDB support - go install ./... +todo....... ## Server Example diff --git a/bootstrap.sh b/bootstrap.sh old mode 100644 new mode 100755 diff --git a/build_config.sh b/build_config.sh new file mode 100755 index 0000000..ce52efd --- /dev/null +++ b/build_config.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +OUTPUT=$1 +PREFIX=$2 +if test -z "$OUTPUT" || test -z "$PREFIX"; then + echo "usage: $0 " >&2 + exit 1 +fi + +# Delete existing output, if it exists +rm -f $OUTPUT +touch $OUTPUT + +source ./dev.sh + +echo "GO_BUILD_TAGS=$GO_BUILD_TAGS" >> $OUTPUT \ No newline at end of file diff --git a/dev.sh b/dev.sh index 76115ba..8183bf4 100644 --- a/dev.sh +++ b/dev.sh @@ -25,35 +25,37 @@ function add_path() fi } +GO_BUILD_TAGS= + export GOPATH=$(add_path $GOPATH $VTROOT) # check snappy if [ -f $SNAPPY_DIR/lib/libsnappy.a ]; then - CGO_CFLAGS+="-I$SNAPPY_DIR/include" - CGO_CXXFLAGS+="-I$SNAPPY_DIR/include" - CGO_LDFLAGS+="-L$SNAPPY_DIR/lib -lsnappy" + CGO_CFLAGS="$CGO_CFLAGS -I$SNAPPY_DIR/include" + CGO_CXXFLAGS="$CGO_CXXFLAGS -I$SNAPPY_DIR/include" + CGO_LDFLAGS="$CGO_LDFLAGS -L$SNAPPY_DIR/lib -lsnappy" LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $SNAPPY_DIR/lib) DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $SNAPPY_DIR/lib) fi # check leveldb if [ -f $LEVELDB_DIR/lib/libleveldb.a ]; then - CGO_CFLAGS+="-I$LEVELDB_DIR/include" - CGO_CXXFLAGS+="-I$LEVELDB_DIR/include" - CGO_LDFLAGS+="-L$LEVELDB_DIR/lib -lleveldb" + CGO_CFLAGS="$CGO_CFLAGS -I$LEVELDB_DIR/include" + CGO_CXXFLAGS="$CGO_CXXFLAGS -I$LEVELDB_DIR/include" + CGO_LDFLAGS="$CGO_LDFLAGS -L$LEVELDB_DIR/lib -lleveldb" LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib) DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $LEVELDB_DIR/lib) - GO_BUILD_TAGS+="leveldb" + GO_BUILD_TAGS="$GO_BUILD_TAGS leveldb" fi # check rocksdb -if [ -f $ROCKSDB_DIR/lib/libleveldb.a ]; then - CGO_CFLAGS+="-I$ROCKSDB_DIR/include" - CGO_CXXFLAGS+="-I$ROCKSDB_DIR/include" - CGO_LDFLAGS+="-L$ROCKSDB_DIR/lib -lleveldb" +if [ -f $ROCKSDB_DIR/lib/librocksdb.a ]; then + CGO_CFLAGS="$CGO_CFLAGS -I$ROCKSDB_DIR/include" + CGO_CXXFLAGS="$CGO_CXXFLAGS -I$ROCKSDB_DIR/include" + CGO_LDFLAGS="$CGO_LDFLAGS -L$ROCKSDB_DIR/lib -lleveldb" LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $ROCKSDB_DIR/lib) DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $ROCKSDB_DIR/lib) - GO_BUILD_TAGS+="rocksdb" + GO_BUILD_TAGS="$GO_BUILD_TAGS rocksdb" fi export CGO_CFLAGS diff --git a/etc/ledis.json b/etc/ledis.json index 89eb922..071bfe1 100644 --- a/etc/ledis.json +++ b/etc/ledis.json @@ -1,7 +1,10 @@ { "addr": "127.0.0.1:6380", "data_dir": "/tmp/ledis_server", + "db": { + "name" : "golveldb", + "compression": false, "block_size": 32768, "write_buffer_size": 67108864,