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
Get(string) (*Item, error)
}
type Setter interface {
RequestHandler
Set(*Item) error
}
type Deleter interface {
RequestHandler
Delete(string) error
}
package main
import (
memcached "github.com/mattrobenolt/go-memcached"
)
type Cache struct {}
func (c *Cache) Get(key string) (item *memcached.Item, err error) {
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