Documentation ¶
Index ¶
- Constants
- Variables
- func InitTokens()
- func NewMapStore() *mapStore
- func WriteFull(w io.Writer, buf []byte) error
- type Item
- type ReqHistoy
- type ReqLimiter
- type Request
- func (req *Request) Check(resp *Response) error
- func (req *Request) Clear()
- func (req *Request) Process(store StorageClient, stat *Stats) (resp *Response, err error)
- func (req *Request) Read(b *bufio.Reader) error
- func (req *Request) SetStat(stat string)
- func (req *Request) String() (s string)
- func (req *Request) Write(w io.Writer) (e error)
- type Response
- type Server
- type ServerConn
- type Stats
- type Storage
- type StorageClient
Constants ¶
View Source
const VERSION = "0.1.0"
Variables ¶
View Source
var ( // ErrInvalidCmd means that the number of command parts is invalid, // or the type of a part if invalid. ErrInvalidCmd = errors.New("invalid cmd") // ErrNonMemcacheCmd means that the command is not defined in original memcache protocal. // refer: https://github.com/memcached/memcached/blob/master/doc/protocol.txt ErrNonMemcacheCmd = errors.New("non memcache command") // ErrValueTooLarge means that the value of a store command (e.g. set) is too large ErrValueTooLarge = errors.New("value too large") // ErrKeyLength means that the length of key is invalid ErrKeyLength = errors.New("key length error") // ErrBadDataChunk means that data chunk of a value is not match its size flag. ErrBadDataChunk = errors.New("bad data chunk") // ErrNetworkError means that a failure happend at reading/writing to a client connection. ErrNetworkError = errors.New("network error") ErrOOM = errors.New("memory shortage") )
Functions ¶
func InitTokens ¶
func InitTokens()
func NewMapStore ¶
func NewMapStore() *mapStore
Types ¶
type ReqLimiter ¶
type ReqLimiter struct { Chan chan int `json:"-"` Owners []*Request `json:"-"` Histories []ReqHistoy // TODO: more! NumWait int32 MaxWait time.Duration }
var ( SlowCmdTime = time.Millisecond * 100 // 100ms RL *ReqLimiter )
func NewReqLimiter ¶
func NewReqLimiter(n int) *ReqLimiter
func (*ReqLimiter) Get ¶
func (rl *ReqLimiter) Get(req *Request)
func (*ReqLimiter) Put ¶
func (rl *ReqLimiter) Put(req *Request)
type Request ¶
type Request struct { ReceiveTime time.Time Cmd string // get, set, delete, quit, etc. Keys []string // keys Item *Item NoReply bool Token int Working bool }
type Response ¶
func (*Response) CleanBuffer ¶
func (resp *Response) CleanBuffer()
type Server ¶
func (*Server) HandleSignals ¶
type ServerConn ¶
type ServerConn struct { RemoteAddr string // contains filtered or unexported fields }
func (*ServerConn) Close ¶
func (c *ServerConn) Close()
func (*ServerConn) Serve ¶
func (c *ServerConn) Serve(storageClient StorageClient, stats *Stats) (e error)
func (*ServerConn) ServeOnce ¶
func (c *ServerConn) ServeOnce(storageClient StorageClient, stats *Stats) (err error)
func (*ServerConn) Shutdown ¶
func (c *ServerConn) Shutdown()
type Storage ¶
type Storage interface {
Client() StorageClient
}
type StorageClient ¶
type StorageClient interface { GetSuccessedTargets() []string Clean() Get(key string) (*Item, error) GetMulti(keys []string) (map[string]*Item, error) Set(key string, item *Item, noreply bool) (bool, error) Append(key string, value []byte) (bool, error) Incr(key string, value int) (int, error) Delete(key string) (bool, error) Len() int Close() Process(key string, args []string) (string, string) }
Click to show internal directories.
Click to hide internal directories.