Documentation ¶
Index ¶
- Variables
- func Crc(key string) string
- func MdFive(key string) string
- func ShaOne(key string) string
- type Config
- type Connection
- func (conn *Connection) Blpop(keys ...string) (interface{}, error)
- func (conn *Connection) Get(key string) (interface{}, error)
- func (conn *Connection) Lpop(key string) (interface{}, error)
- func (conn *Connection) Lpush(key string, value interface{}) error
- func (conn *Connection) Rpop(key string) (interface{}, error)
- func (conn *Connection) Rpush(key string, value interface{}) error
- func (conn *Connection) Set(key string, value interface{}) error
- type HashRing
- type Shardis
- func (shard *Shardis) Blpop(key string) (interface{}, error)
- func (shard *Shardis) Get(key string) (interface{}, error)
- func (shard *Shardis) GetServer(key string) *Connection
- func (shard *Shardis) GetServerName(key string) string
- func (shard *Shardis) Lpop(key string) (interface{}, error)
- func (shard *Shardis) Lpush(key string, value interface{}) error
- func (shard *Shardis) Rpop(key string) (interface{}, error)
- func (shard *Shardis) Rpush(key string, value interface{}) error
- func (shard *Shardis) Set(key string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( //HashMethods maps the name to implementation of a hashing method HashMethods = map[string]interface{}{ "crc32": Crc, "md5": MdFive, "sha1": ShaOne, } )
var (
// RegexFormat is a regex string used to extract substring enclosed by "{" and "}"
RegexFormat = "{.*}"
)
Functions ¶
Types ¶
type Config ¶
type Config struct { Servers []map[string]interface{} `json:"servers"` HashMethod string `json:"hash"` Replicas int `json:"replicas"` }
Config represents the configuration of Shardis
func InitConfig ¶
InitConfig reads config.json and create corresponding Config object
type Connection ¶
Connection represents the connection to a single Redis instance
func NewConnection ¶
func NewConnection(host string, password string, blockTimeout int) *Connection
NewConnection creats a new Connection instance
func (*Connection) Blpop ¶
func (conn *Connection) Blpop(keys ...string) (interface{}, error)
Blpop for calling Redis SET command on a single instance
func (*Connection) Get ¶
func (conn *Connection) Get(key string) (interface{}, error)
Get for calling Redis SET command on a single instance
func (*Connection) Lpop ¶
func (conn *Connection) Lpop(key string) (interface{}, error)
Lpop for calling Redis SET command on a single instance
func (*Connection) Lpush ¶
func (conn *Connection) Lpush(key string, value interface{}) error
Lpush for calling Redis SET command on a single instance
func (*Connection) Rpop ¶
func (conn *Connection) Rpop(key string) (interface{}, error)
Rpop for calling Redis SET command on a single instance
func (*Connection) Rpush ¶
func (conn *Connection) Rpush(key string, value interface{}) error
Rpush for calling Redis SET command on a single instance
func (*Connection) Set ¶
func (conn *Connection) Set(key string, value interface{}) error
Set for calling Redis SET command on a single instance
type HashRing ¶
type HashRing struct { HashMethod string Nodes []string Replicas int Ring map[string]string SortedKeys []string }
HashRing represents a ring of Redis instance involved in Shardis
func NewHashRing ¶
NewHashRing initilizes a new HashRing object
func (*HashRing) RemoveNode ¶
RemoveNode removes the given node from HashRing
type Shardis ¶
type Shardis struct { Nodes []string Connections map[string]*Connection Ring *HashRing }
Shardis represents a sharis client
func (*Shardis) GetServer ¶
func (shard *Shardis) GetServer(key string) *Connection
GetServer gets connection of the server that given key is mapped to
func (*Shardis) GetServerName ¶
GetServerName gets name of the server that given key is hashed to