mirror of https://github.com/ledisdb/ledisdb.git
update document
This commit is contained in:
commit
d45a82897f
10
README.md
10
README.md
|
@ -34,11 +34,11 @@ Ledisdb is a high performance nosql like redis based on leveldb written by go. I
|
||||||
./ledis-server -config=/etc/ledis.json
|
./ledis-server -config=/etc/ledis.json
|
||||||
|
|
||||||
//another shell
|
//another shell
|
||||||
redis-cli -p 6380
|
ledis-cli -p 6380
|
||||||
|
|
||||||
redis 127.0.0.1:6380> set a 1
|
ledis 127.0.0.1:6380> set a 1
|
||||||
OK
|
OK
|
||||||
redis 127.0.0.1:6380> get a
|
ledis 127.0.0.1:6380> get a
|
||||||
"1"
|
"1"
|
||||||
|
|
||||||
## Lib
|
## Lib
|
||||||
|
@ -56,9 +56,9 @@ Ledisdb is a high performance nosql like redis based on leveldb written by go. I
|
||||||
|
|
||||||
set slaveof in config or dynamiclly
|
set slaveof in config or dynamiclly
|
||||||
|
|
||||||
redis-cli -p 6381
|
ledis-cli -p 6381
|
||||||
|
|
||||||
redis 127.0.0.1:6381> slaveof 127.0.0.1:6380
|
ledis 127.0.0.1:6381> slaveof 127.0.0.1:6380
|
||||||
OK
|
OK
|
||||||
|
|
||||||
## Benchmark
|
## Benchmark
|
||||||
|
|
10
README_CN.md
10
README_CN.md
|
@ -41,11 +41,11 @@ ledisdb是一个用go实现的类似redis的高性能nosql数据库,底层基
|
||||||
./ledis-server -config=/etc/ledis.json
|
./ledis-server -config=/etc/ledis.json
|
||||||
|
|
||||||
//another shell
|
//another shell
|
||||||
redis-cli -p 6380
|
ledis-cli -p 6380
|
||||||
|
|
||||||
redis 127.0.0.1:6380> set a 1
|
ledis 127.0.0.1:6380> set a 1
|
||||||
OK
|
OK
|
||||||
redis 127.0.0.1:6380> get a
|
ledis 127.0.0.1:6380> get a
|
||||||
"1"
|
"1"
|
||||||
|
|
||||||
## 嵌入库
|
## 嵌入库
|
||||||
|
@ -66,9 +66,9 @@ ledisdb是一个用go实现的类似redis的高性能nosql数据库,底层基
|
||||||
|
|
||||||
通过配置或者运行时输入slaveof开启slave的replication功能
|
通过配置或者运行时输入slaveof开启slave的replication功能
|
||||||
|
|
||||||
redis-cli -p 6381
|
ledis-cli -p 6381
|
||||||
|
|
||||||
redis 127.0.0.1:6381> slaveof 127.0.0.1:6380
|
ledis 127.0.0.1:6381> slaveof 127.0.0.1:6380
|
||||||
OK
|
OK
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Package ledis is a client for the ledisdb.
|
||||||
|
|
||||||
|
// Config
|
||||||
|
|
||||||
|
// Config struct contains configuration for ledisdb:
|
||||||
|
|
||||||
|
// Addr ledisdb server address, like 127.0.0.1:6380
|
||||||
|
// MaxIdleConns max idle connections for ledisdb
|
||||||
|
|
||||||
|
// Client
|
||||||
|
|
||||||
|
// The client is the primary interface for ledisdb. You must first create a client with proper config for working.
|
||||||
|
|
||||||
|
// cfg := new(Config)
|
||||||
|
// cfg.Addr = "127.0.0.1:6380"
|
||||||
|
// cfg.MaxIdleConns = 4
|
||||||
|
|
||||||
|
// c := NewClient(cfg)
|
||||||
|
|
||||||
|
// The most important function for client is Do function to send commands to remote server.
|
||||||
|
|
||||||
|
// reply, err := c.Do("ping")
|
||||||
|
|
||||||
|
// reply, err := c.Do("set", "key", "value")
|
||||||
|
|
||||||
|
// reply, err := c.Do("get", "key")
|
||||||
|
|
||||||
|
// Connection
|
||||||
|
|
||||||
|
// You can use an independent connection to send commands.
|
||||||
|
|
||||||
|
// //get a connection
|
||||||
|
// conn := c.Get()
|
||||||
|
|
||||||
|
// //connection send command
|
||||||
|
// conn.Do("ping")
|
||||||
|
|
||||||
|
// Reply Helper
|
||||||
|
|
||||||
|
// You can use reply helper to convert a reply to a specific type.
|
||||||
|
|
||||||
|
// exists, err := ledis.Bool(c.Do("exists", "key"))
|
||||||
|
|
||||||
|
// score, err := ledis.Int64(c.Do("zscore", "key", "member"))
|
||||||
|
package ledis
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Package ledis is a high performance embedded NoSQL based on leveldb.
|
||||||
|
// Ledis supports various advanced data structure like kv, list, hash and zset like redis.
|
||||||
|
|
||||||
|
// Other features include binlog replication, data with a limited time-to-live.
|
||||||
|
|
||||||
|
// First create a ledis instance before use:
|
||||||
|
|
||||||
|
// l := ledis.OpenWithConfig(cfg)
|
||||||
|
|
||||||
|
// cfg is a Config instance which contains configuration for ledis use,
|
||||||
|
// like DataDir (root directory for ledis working to store data).
|
||||||
|
|
||||||
|
// After you create a ledis instance, you can select a DB to store you data:
|
||||||
|
|
||||||
|
// db, _ := l.Select(0)
|
||||||
|
|
||||||
|
// DB must be selected by a index, ledis supports only 16 databases, so the index range is [0-15].
|
||||||
|
|
||||||
|
// KV
|
||||||
|
|
||||||
|
// KV is the most basic ledis type like any other key-value database.
|
||||||
|
|
||||||
|
// err := db.Set(key, value)
|
||||||
|
// value, err := db.Get(key)
|
||||||
|
|
||||||
|
// List
|
||||||
|
|
||||||
|
// List is simply lists of values, sorted by insertion order.
|
||||||
|
// You can push or pop value on the list head (left) or tail (right).
|
||||||
|
|
||||||
|
// err := db.LPush(key, value1)
|
||||||
|
// err := db.RPush(key, value2)
|
||||||
|
// value1, err := db.LPop(key)
|
||||||
|
// value2, err := db.RPop(key)
|
||||||
|
|
||||||
|
// Hash
|
||||||
|
|
||||||
|
// Hash is a map between fields and values.
|
||||||
|
|
||||||
|
// n, err := db.HSet(key, field1, value1)
|
||||||
|
// n, err := db.HSet(key, field2, value2)
|
||||||
|
// value1, err := db.HGet(key, field1)
|
||||||
|
// value2, err := db.HGet(key, field2)
|
||||||
|
|
||||||
|
// ZSet
|
||||||
|
|
||||||
|
// ZSet is a sorted collections of values.
|
||||||
|
// Every member of zset is associated with score, a int64 value which used to sort, from smallest to greatest score.
|
||||||
|
// Members are unique, but score may be same.
|
||||||
|
|
||||||
|
// n, err := db.ZAdd(key, ScorePair{score1, member1}, ScorePair{score2, member2})
|
||||||
|
// ay, err := db.ZRangeByScore(key, minScore, maxScore, 0, -1)
|
||||||
|
|
||||||
|
// Binlog
|
||||||
|
// ledis supports binlog, so you can sync binlog to another server for replication. If you want to open binlog support, set UseBinLog to true in config.
|
||||||
|
package ledis
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Package server supplies a way to use ledis as service.
|
||||||
|
// Server implements the redis protocol called RESP (REdis Serialization Protocol).
|
||||||
|
// For more information, please see http://redis.io/topics/protocol.
|
||||||
|
|
||||||
|
// You can use ledis with many available redis clients directly, for example, redis-cli.
|
||||||
|
// But I also supply some ledis client at client folder, and have been adding more for other languages.
|
||||||
|
|
||||||
|
// Start a ledis server is very simple:
|
||||||
|
|
||||||
|
// cfg := new(Config)
|
||||||
|
// cfg.Addr = "127.0.0.1:6380"
|
||||||
|
// cfg.DataDir = "/tmp/ledis"
|
||||||
|
// app := server.NewApp(cfg)
|
||||||
|
// app.Run()
|
||||||
|
|
||||||
|
// Replication
|
||||||
|
// You can start a slave ledis server for replication, open slave is simple too, you can set slaveof in config or run slaveof command in shell.
|
||||||
|
|
||||||
|
// For example, if you start a slave server, and the master server's address is 127.0.0.1:6380, you can start replication in shell:
|
||||||
|
|
||||||
|
// ledis-cli -p 6381
|
||||||
|
// ledis 127.0.0.1:6381 > slaveof 127.0.0.1 6380
|
||||||
|
|
||||||
|
// After you send slaveof command, the slave will start to sync master's binlog and replicate from binlog.
|
||||||
|
package server
|
Loading…
Reference in New Issue