ledisdb/README.md

175 lines
4.4 KiB
Markdown
Raw Normal View History

2014-07-10 05:29:34 +04:00
# LedisDB
2014-05-22 04:52:38 +04:00
2014-08-15 20:08:01 +04:00
Ledisdb is a high performance NoSQL like Redis written by go. It supports some data structure like kv, list, hash, zset, bitmap,set, and may be alternative for Redis.
2014-07-26 05:22:09 +04:00
2014-08-12 10:44:16 +04:00
LedisDB now supports multiple databases as backend to store data, you can test and choose the proper one for you.
2014-05-22 04:52:38 +04:00
2014-07-11 13:30:40 +04:00
## Features
2014-08-15 20:08:01 +04:00
+ Rich data structure: KV, List, Hash, ZSet, Bitmap, Set.
2014-07-26 05:22:09 +04:00
+ Stores lots of data, over the memory limit.
2014-08-12 10:44:16 +04:00
+ Various backend database to use: LevelDB, goleveldb, LMDB, RocksDB, BoltDB, HyperLevelDB.
2014-07-11 13:30:40 +04:00
+ Supports expiration and ttl.
+ Redis clients, like redis-cli, are supported directly.
2014-08-12 10:49:02 +04:00
+ Multiple client API supports, including Go, Python, Lua(Openresty), C/C++, Node.js.
2014-08-06 05:30:44 +04:00
+ Easy to embed in your own Go application.
2014-08-04 12:29:10 +04:00
+ Restful API support, json/bson/msgpack output.
2014-07-11 13:30:40 +04:00
+ Replication to guarantee data safe.
+ Supplies tools to load, dump, repair database.
2014-05-22 04:52:38 +04:00
## Build and Install
2014-07-26 05:22:09 +04:00
Create a workspace and checkout ledisdb source
mkdir $WORKSPACE
cd $WORKSPACE
git clone git@github.com:siddontang/ledisdb.git src/github.com/siddontang/ledisdb
cd src/github.com/siddontang/ledisdb
2014-05-22 04:52:38 +04:00
2014-07-28 10:20:18 +04:00
#set build and run environment
source dev.sh
2014-07-28 08:46:17 +04:00
make
make test
2014-05-22 04:52:38 +04:00
2014-07-28 10:20:18 +04:00
2014-07-26 05:22:09 +04:00
## LevelDB support
2014-05-22 04:52:38 +04:00
2014-07-26 14:39:54 +04:00
+ Install leveldb and snappy.
2014-05-22 04:52:38 +04:00
2014-07-27 03:01:01 +04:00
LedisDB supplies a simple script to install leveldb and snappy:
2014-05-22 04:52:38 +04:00
2014-08-19 16:38:34 +04:00
sudo sh build_tool/build_leveldb.sh
2014-05-22 04:52:38 +04:00
2014-07-21 06:46:11 +04:00
It will default install leveldb at /usr/local/leveldb and snappy at /usr/local/snappy.
2014-07-21 06:47:25 +04:00
LedisDB use the modified LevelDB for better performance, see [here](https://github.com/siddontang/ledisdb/wiki/leveldb-source-modification).
2014-05-22 04:52:38 +04:00
2014-07-28 10:36:03 +04:00
+ Set ```LEVELDB_DIR``` and ```SNAPPY_DIR``` to the actual install path in dev.sh.
2014-07-28 08:46:17 +04:00
+ ```make```
2014-05-22 04:52:38 +04:00
2014-07-26 05:22:09 +04:00
## RocksDB support
2014-05-22 04:52:38 +04:00
2014-08-12 10:44:16 +04:00
+ [Install rocksdb](https://github.com/facebook/rocksdb/blob/master/INSTALL.md)(`make shared_lib`) and snappy first.
2014-07-26 14:39:54 +04:00
2014-07-28 08:46:17 +04:00
LedisDB has not supplied a simple script to install, maybe later.
2014-07-26 14:39:54 +04:00
2014-08-12 10:44:16 +04:00
+ Set ```ROCKSDB_DIR``` and ```SNAPPY_DIR``` to the actual install path in `dev.sh`.
2014-07-28 08:46:17 +04:00
+ ```make```
2014-07-26 14:39:54 +04:00
2014-08-12 10:44:16 +04:00
## HyperLevelDB support
+ [Install hyperleveldb](https://github.com/rescrv/HyperLevelDB/blob/master/README) and snappy first.
LedisDB has not supplied a simple script to install, maybe later.
+ Set `HYPERLEVELDB` and `SNAPPY_DIR` to the actual install path in `dev.sh`.
+ `make`
2014-07-26 14:39:54 +04:00
## Choose store database
2014-08-12 10:44:16 +04:00
LedisDB now supports goleveldb, lmdb, leveldb, rocksdb, boltdb, hyperleveldb. it will choose goleveldb as default to store data if you not set.
2014-07-26 14:39:54 +04:00
Choosing a store database to use is very simple, you have two ways:
+ Set in server config file
db_name = "leveldb"
2014-07-26 14:39:54 +04:00
+ Set in command flag
ledis-server -config=/etc/ledis.conf -db_name=leveldb
2014-07-26 14:39:54 +04:00
Flag command set will overwrite config set.
**Caveat**
You must known that changing store database runtime is very dangerous, LedisDB will not guarantee the data validation if you do it.
2014-05-22 04:52:38 +04:00
## Configuration
LedisDB uses [toml](https://github.com/toml-lang/toml) as the preferred configuration format, also supports ```json``` because of some history reasons. The basic configuration ```./etc/ledis.conf``` in LedisDB source may help you.
If you don't use a configuration, LedisDB will use the default for you.
2014-07-21 06:46:11 +04:00
## Server Example
2014-07-28 10:20:18 +04:00
//set run environment if not
source dev.sh
2014-05-22 04:52:38 +04:00
ledis-server -config=/etc/ledis.conf
2014-05-22 04:52:38 +04:00
2014-06-12 11:56:04 +04:00
//another shell
2014-06-22 17:05:52 +04:00
ledis-cli -p 6380
2014-06-12 11:56:04 +04:00
2014-06-22 17:05:52 +04:00
ledis 127.0.0.1:6380> set a 1
2014-06-12 11:56:04 +04:00
OK
2014-06-22 17:05:52 +04:00
ledis 127.0.0.1:6380> get a
2014-06-12 11:56:04 +04:00
"1"
2014-08-04 07:55:39 +04:00
//use curl
curl http://127.0.0.1:11181/SET/hello/world
→ {"SET":[true,"OK"]}
curl http://127.0.0.1:11181/0/GET/hello?type=json
→ {"GET":"world"}
2014-07-21 06:46:11 +04:00
## Package Example
2014-06-12 11:56:04 +04:00
import "github.com/siddontang/ledisdb/ledis"
l, _ := ledis.Open(cfg)
2014-06-12 11:56:04 +04:00
db, _ := l.Select(0)
db.Set(key, value)
db.Get(key)
2014-07-21 06:46:11 +04:00
## Replication Example
2014-06-12 11:56:04 +04:00
2014-07-16 10:34:08 +04:00
Set slaveof in config or dynamiclly
2014-06-12 11:56:04 +04:00
2014-06-22 17:05:52 +04:00
ledis-cli -p 6381
2014-06-12 11:56:04 +04:00
2014-07-24 08:16:42 +04:00
ledis 127.0.0.1:6381> slaveof 127.0.0.1 6380
2014-06-12 11:56:04 +04:00
OK
2014-05-22 04:52:38 +04:00
## Benchmark
2014-07-28 10:31:31 +04:00
See [benchmark](https://github.com/siddontang/ledisdb/wiki/Benchmark) for more.
2014-05-22 04:52:38 +04:00
## Todo
2014-07-21 06:46:11 +04:00
See [Issues todo](https://github.com/siddontang/ledisdb/issues?labels=todo&page=1&state=open)
2014-05-22 04:52:38 +04:00
2014-06-30 07:48:09 +04:00
2014-07-16 12:58:03 +04:00
## Links
2014-06-30 07:48:09 +04:00
2014-07-16 12:58:03 +04:00
+ [Official Website](http://ledisdb.com)
2014-07-16 12:59:42 +04:00
+ [GoDoc](https://godoc.org/github.com/siddontang/ledisdb)
2014-07-16 12:59:59 +04:00
+ [Server Commands](https://github.com/siddontang/ledisdb/wiki/Commands)
2014-06-30 07:48:09 +04:00
2014-06-12 11:58:50 +04:00
## Thanks
2014-07-02 06:23:13 +04:00
Gmail: cenqichao@gmail.com
2014-07-09 05:33:44 +04:00
2014-07-02 06:23:13 +04:00
Gmail: chendahui007@gmail.com
2014-06-12 11:58:50 +04:00
2014-07-21 06:46:11 +04:00
Gmail: cppgohan@gmail.com
Gmail: tiaotiaoyly@gmail.com
Gmail: wyk4true@gmail.com
2014-07-16 10:34:08 +04:00
2014-05-22 04:52:38 +04:00
## Feedback
2014-07-16 12:59:59 +04:00
Gmail: siddontang@gmail.com