Modeled similarly to the stdlib net/http
package, memcached
gives you a simple interface to building your own memcached protocol compatible applications.
$ go get github.com/mattrobenolt/go-memcached
Implement as little or as much as you'd like.
type Getter interface {
RequestHandler
GetWithContext(*context.Context, string) MemcachedResponse
}
type Setter interface {
RequestHandler
SetWithContext(*context.Context, *Item) MemcachedResponse
}
type Deleter interface {
RequestHandler
DeleteWithContext(*context.Context, string) MemcachedResponse
}
package main
import (
memcached "github.com/ialx/go-memcached"
)
type Cache struct {}
func (c *Cache) GetWithContext(ctx *context.Context, key string) memcached.MemcachedResponse {
if key == "hello" {
item = &memcached.Item{
Key: key,
Value: []byte("world"),
}
return item, nil
}
return nil, memcached.NotFound
}
func main() {
server := memcached.NewServer(":11211", &Cache{})
server.ListenAndServe()
}
- Simple Memcached Don't actually use this