2014-06-22 17:05:52 +04:00
|
|
|
// 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.
|
2014-06-22 17:13:57 +04:00
|
|
|
//
|
2014-06-22 17:05:52 +04:00
|
|
|
// 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.
|
2014-06-22 17:13:57 +04:00
|
|
|
//
|
2014-06-25 08:57:19 +04:00
|
|
|
// Usage
|
|
|
|
//
|
2014-06-22 17:05:52 +04:00
|
|
|
// Start a ledis server is very simple:
|
2014-06-22 17:13:57 +04:00
|
|
|
//
|
2014-10-11 12:00:59 +04:00
|
|
|
// cfg := config.NewConfigDefault()
|
2014-06-22 17:05:52 +04:00
|
|
|
// cfg.Addr = "127.0.0.1:6380"
|
|
|
|
// cfg.DataDir = "/tmp/ledis"
|
|
|
|
// app := server.NewApp(cfg)
|
|
|
|
// app.Run()
|
2014-06-22 17:13:57 +04:00
|
|
|
//
|
2014-06-22 17:05:52 +04:00
|
|
|
// Replication
|
2014-06-25 08:57:19 +04:00
|
|
|
//
|
2014-06-22 17:05:52 +04:00
|
|
|
// 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.
|
2014-06-22 17:13:57 +04:00
|
|
|
//
|
2014-06-22 17:05:52 +04:00
|
|
|
// 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:
|
2014-06-22 17:13:57 +04:00
|
|
|
//
|
2014-06-22 17:05:52 +04:00
|
|
|
// ledis-cli -p 6381
|
|
|
|
// ledis 127.0.0.1:6381 > slaveof 127.0.0.1 6380
|
2014-06-22 17:13:57 +04:00
|
|
|
//
|
2014-09-23 13:28:09 +04:00
|
|
|
// After you send slaveof command, the slave will start to sync master's write ahead log and replicate from it.
|
|
|
|
// You must notice that use_replication must be set true if you want to use it.
|
2014-06-25 08:57:19 +04:00
|
|
|
//
|
2014-08-04 06:47:10 +04:00
|
|
|
// HTTP Interface
|
2014-08-04 10:13:35 +04:00
|
|
|
//
|
2014-08-04 06:47:10 +04:00
|
|
|
// LedisDB provides http interfaces for most commands(except the replication commands)
|
|
|
|
//
|
2014-08-04 10:13:35 +04:00
|
|
|
// curl http://127.0.0.1:11181/SET/hello/world
|
|
|
|
// → {"SET":[true,"OK"]}
|
2014-08-04 06:47:10 +04:00
|
|
|
//
|
2014-08-04 10:13:35 +04:00
|
|
|
// curl http://127.0.0.1:11181/0/GET/hello?type=json
|
|
|
|
// → {"GET":"world"}
|
2014-08-04 06:47:10 +04:00
|
|
|
//
|
2014-06-22 17:05:52 +04:00
|
|
|
package server
|