Documentation
¶
Overview ¶
Package memcached provides an interface for building your own memcached ascii protocol servers.
Index ¶
Constants ¶
const ( UserTime usageType = iota SystemTime )
const ( StatusEnd = "END\r\n" StatusError = "ERROR\r\n" StatusServerError = "SERVER_ERROR\r\n" StatusClientError = "CLIENT_ERROR %s\r\n" StatusStored = "STORED\r\n" StatusNotStored = "NOT_STORED\r\n" StatusExists = "EXISTS\r\n" StatusNotFound = "NOT_FOUND\r\n" StatusDeleted = "DELETED\r\n" StatusTouched = "TOUCHED\r\n" StatusOK = "OK\r\n" StatusVersion = "VERSION %s\r\n" StatusValue = "VALUE %s %d %d\r\n" StatusStat = "STAT %s %s\r\n" )
const MAX_EXPTIME = 60 * 60 * 24 * 30 // 30 days
MAX_EXPTIME is the maximum time to send from a client before the timestamp is considered an absolute unix timestamp.
const VERSION = "0.0.0"
Variables ¶
var ( // ClientError is an error caused by an invalid command from the client. ClientError = errors.New(StatusClientError) // NotFound is returned when the key was not found. NotFound = errors.New(StatusNotFound) // ServerError is an error occurred servicing this request. ServerError = errors.New(StatusServerError) // Error is a generic error. Error = errors.New(StatusError) )
Functions ¶
This section is empty.
Types ¶
type BulkResponse ¶
type BulkResponse struct {
Responses []MemcachedResponse
}
func (*BulkResponse) WriteResponse ¶
func (r *BulkResponse) WriteResponse(writer io.Writer)
type ClientErrorResponse ¶
type ClientErrorResponse struct {
Reason string
}
func (*ClientErrorResponse) WriteResponse ¶
func (r *ClientErrorResponse) WriteResponse(writer io.Writer)
type CounterStat ¶
type CounterStat struct { Count int // contains filtered or unexported fields }
func NewCounterStat ¶
func NewCounterStat() *CounterStat
func (*CounterStat) Decrement ¶
func (c *CounterStat) Decrement(num int)
func (*CounterStat) Increment ¶
func (c *CounterStat) Increment(num int)
func (*CounterStat) SetCount ¶
func (c *CounterStat) SetCount(num int)
func (*CounterStat) String ¶
func (c *CounterStat) String() string
type Deleter ¶
type Deleter interface { RequestHandler Delete(string) MemcachedResponse }
A Deleter is an object who responds to a simple "delete" command.
type Getter ¶
type Getter interface { RequestHandler Get(string) MemcachedResponse }
A Getter is an object who responds to a simple "get" command.
type Item ¶
func (*Item) IsExpired ¶
IsExpired checks if an Item is expired based on it's Ttl. If an item has no Ttl set, it is considered to never be expired.
func (*Item) SetExpires ¶
SetExpires sets the Ttl and Expires based on the exptime send from a client. This follows standard memcached rules, and an exptime greater than 30 days is treated as an absolute unix timestamp.
type ItemResponse ¶
type ItemResponse struct {
Item *Item
}
func (*ItemResponse) WriteResponse ¶
func (r *ItemResponse) WriteResponse(writer io.Writer)
type MemcachedResponse ¶
type RequestHandler ¶
type RequestHandler interface{}
type Server ¶
func NewServer ¶
func NewServer(listen string, handler RequestHandler) *Server
NewServer initialize a new memcached Server.
func (*Server) ListenAndServe ¶
ListenAndServe starts listening and accepting requests to this server.
type Setter ¶
type Setter interface { RequestHandler Set(*Item) MemcachedResponse }
A Setter is an object who response to a simple "set" command.
type StaticStat ¶
type StaticStat struct {
Value string
}
func (*StaticStat) String ¶
func (s *StaticStat) String() string
type Stats ¶
type Stats struct { PID *StaticStat Uptime *TimerStat Time *FuncStat Version *StaticStat Golang *StaticStat Goroutines *FuncStat RUsageUser *FuncStat RUsageSystem *FuncStat CMDGet *CounterStat CMDSet *CounterStat GetHits *CounterStat GetMisses *CounterStat CurrConnections *CounterStat TotalConnections *CounterStat Evictions *CounterStat }