ledisdb: github.com/siddontang/ledisdb/server Index | Files

package server

import "github.com/siddontang/ledisdb/server"

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.

Usage

Start a ledis server is very simple:

cfg := config.NewConfigDefault()
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 write ahead log and replicate from it. You must notice that use_replication must be set true if you want to use it.

HTTP Interface

LedisDB provides http interfaces for most commands(except the replication commands)

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"}

Index

Package Files

accesslog.go app.go client.go client_http.go client_resp.go cmd_hash.go cmd_kv.go cmd_list.go cmd_migrate.go cmd_replication.go cmd_scan.go cmd_script.go cmd_server.go cmd_set.go cmd_sort.go cmd_zset.go command.go const.go doc.go info.go replication.go script.go snapshot.go util.go

Constants

const (
    KV   ledis.DataType = ledis.KV
    LIST                = ledis.LIST
    HASH                = ledis.HASH
    SET                 = ledis.SET
    ZSET                = ledis.ZSET
)
const (
    KVName   = ledis.KVName
    ListName = ledis.ListName
    HashName = ledis.HashName
    SetName  = ledis.SetName
    ZSetName = ledis.ZSetName
)
const (
    GB  uint64 = 1024 * 1024 * 1024
    MB  uint64 = 1024 * 1024
    KB  uint64 = 1024
)

Variables

var (
    ErrEmptyCommand          = errors.New("empty command")
    ErrNotFound              = errors.New("command not found")
    ErrNotAuthenticated      = errors.New("not authenticated")
    ErrAuthenticationFailure = errors.New("authentication failure")
    ErrCmdParams             = errors.New("invalid command param")
    ErrValue                 = errors.New("value is not an integer or out of range")
    ErrSyntax                = errors.New("syntax error")
    ErrOffset                = errors.New("offset bit is not an natural number")
    ErrBool                  = errors.New("value is not 0 or 1")
)
var (
    Delims = []byte("\r\n")

    NullBulk  = []byte("-1")
    NullArray = []byte("-1")

    PONG  = "PONG"
    OK    = "OK"
    NOKEY = "NOKEY"
)
var TypeNames = []string{KVName, ListName, HashName, SetName, ZSetName}

type App Uses

type App struct {
    // contains filtered or unexported fields
}

func NewApp Uses

func NewApp(cfg *config.Config) (*App, error)

func (*App) Address Uses

func (app *App) Address() string

func (*App) Close Uses

func (app *App) Close()

func (*App) Ledis Uses

func (app *App) Ledis() *ledis.Ledis

func (*App) Run Uses

func (app *App) Run()

type CommandFunc Uses

type CommandFunc func(c *client) error

Package server imports 37 packages (graph) and is imported by 4 packages. Updated 2017-06-20. Refresh now. Tools for package owners.