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