update document

This commit is contained in:
siddontang 2014-06-22 21:13:57 +08:00
parent d45a82897f
commit 794cb12ba4
3 changed files with 46 additions and 46 deletions

View File

@ -1,45 +1,45 @@
// Package ledis is a client for the ledisdb. // Package ledis is a client for the ledisdb.
//
// Config // Config
//
// Config struct contains configuration for ledisdb: // Config struct contains configuration for ledisdb:
//
// Addr ledisdb server address, like 127.0.0.1:6380 // Addr ledisdb server address, like 127.0.0.1:6380
// MaxIdleConns max idle connections for ledisdb // MaxIdleConns max idle connections for ledisdb
//
// Client // Client
//
// The client is the primary interface for ledisdb. You must first create a client with proper config for working. // The client is the primary interface for ledisdb. You must first create a client with proper config for working.
//
// cfg := new(Config) // cfg := new(Config)
// cfg.Addr = "127.0.0.1:6380" // cfg.Addr = "127.0.0.1:6380"
// cfg.MaxIdleConns = 4 // cfg.MaxIdleConns = 4
//
// c := NewClient(cfg) // c := NewClient(cfg)
//
// The most important function for client is Do function to send commands to remote server. // The most important function for client is Do function to send commands to remote server.
//
// reply, err := c.Do("ping") // reply, err := c.Do("ping")
//
// reply, err := c.Do("set", "key", "value") // reply, err := c.Do("set", "key", "value")
//
// reply, err := c.Do("get", "key") // reply, err := c.Do("get", "key")
//
// Connection // Connection
//
// You can use an independent connection to send commands. // You can use an independent connection to send commands.
//
// //get a connection // //get a connection
// conn := c.Get() // conn := c.Get()
//
// //connection send command // //connection send command
// conn.Do("ping") // conn.Do("ping")
//
// Reply Helper // Reply Helper
//
// You can use reply helper to convert a reply to a specific type. // You can use reply helper to convert a reply to a specific type.
//
// exists, err := ledis.Bool(c.Do("exists", "key")) // exists, err := ledis.Bool(c.Do("exists", "key"))
//
// score, err := ledis.Int64(c.Do("zscore", "key", "member")) // score, err := ledis.Int64(c.Do("zscore", "key", "member"))
package ledis package ledis

View File

@ -1,56 +1,56 @@
// Package ledis is a high performance embedded NoSQL based on leveldb. // 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. // 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. // Other features include binlog replication, data with a limited time-to-live.
//
// First create a ledis instance before use: // First create a ledis instance before use:
//
// l := ledis.OpenWithConfig(cfg) // l := ledis.OpenWithConfig(cfg)
//
// cfg is a Config instance which contains configuration for ledis use, // cfg is a Config instance which contains configuration for ledis use,
// like DataDir (root directory for ledis working to store data). // 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: // After you create a ledis instance, you can select a DB to store you data:
//
// db, _ := l.Select(0) // db, _ := l.Select(0)
//
// DB must be selected by a index, ledis supports only 16 databases, so the index range is [0-15]. // DB must be selected by a index, ledis supports only 16 databases, so the index range is [0-15].
//
// KV // KV
//
// KV is the most basic ledis type like any other key-value database. // KV is the most basic ledis type like any other key-value database.
//
// err := db.Set(key, value) // err := db.Set(key, value)
// value, err := db.Get(key) // value, err := db.Get(key)
//
// List // List
//
// List is simply lists of values, sorted by insertion order. // List is simply lists of values, sorted by insertion order.
// You can push or pop value on the list head (left) or tail (right). // You can push or pop value on the list head (left) or tail (right).
//
// err := db.LPush(key, value1) // err := db.LPush(key, value1)
// err := db.RPush(key, value2) // err := db.RPush(key, value2)
// value1, err := db.LPop(key) // value1, err := db.LPop(key)
// value2, err := db.RPop(key) // value2, err := db.RPop(key)
//
// Hash // Hash
//
// Hash is a map between fields and values. // Hash is a map between fields and values.
//
// n, err := db.HSet(key, field1, value1) // n, err := db.HSet(key, field1, value1)
// n, err := db.HSet(key, field2, value2) // n, err := db.HSet(key, field2, value2)
// value1, err := db.HGet(key, field1) // value1, err := db.HGet(key, field1)
// value2, err := db.HGet(key, field2) // value2, err := db.HGet(key, field2)
//
// ZSet // ZSet
//
// ZSet is a sorted collections of values. // 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. // 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. // Members are unique, but score may be same.
//
// n, err := db.ZAdd(key, ScorePair{score1, member1}, ScorePair{score2, member2}) // n, err := db.ZAdd(key, ScorePair{score1, member1}, ScorePair{score2, member2})
// ay, err := db.ZRangeByScore(key, minScore, maxScore, 0, -1) // ay, err := db.ZRangeByScore(key, minScore, maxScore, 0, -1)
//
// Binlog // 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. // 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 package ledis

View File

@ -1,25 +1,25 @@
// Package server supplies a way to use ledis as service. // Package server supplies a way to use ledis as service.
// Server implements the redis protocol called RESP (REdis Serialization Protocol). // Server implements the redis protocol called RESP (REdis Serialization Protocol).
// For more information, please see http://redis.io/topics/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. // 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. // 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: // Start a ledis server is very simple:
//
// cfg := new(Config) // cfg := new(Config)
// cfg.Addr = "127.0.0.1:6380" // cfg.Addr = "127.0.0.1:6380"
// cfg.DataDir = "/tmp/ledis" // cfg.DataDir = "/tmp/ledis"
// app := server.NewApp(cfg) // app := server.NewApp(cfg)
// app.Run() // app.Run()
//
// Replication // 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. // 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: // 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-cli -p 6381
// ledis 127.0.0.1:6381 > slaveof 127.0.0.1 6380 // 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. // After you send slaveof command, the slave will start to sync master's binlog and replicate from binlog.
package server package server