In-memory cache with HTTP REST interface
147
A simple in-memory cache with HTTP REST interface.
package main
import (
"fmt"
"time"
memcache "github.com/abhi195/go-mem-cache"
)
func main() {
// creating cache with default 30 minutes of TTL which
// evicts expired entries every 60 minutes
mc := memcache.New()
// alternatively you can use NewWith() to
// create cache with required values
nmc := memcache.NewWith(1*time.Minute, 2*time.Minute)
// set key, value
mc.Set("foo", "bar")
// get key
v, exist := mc.Get("foo")
if exist {
fmt.Println(v)
}
}
GET /api/v1/cache/{key}
POST /api/v1/cache/{key} # with plain text body for value
Please import go-mem-cache.postman_collection.json for sample requests.
go build -o ./out/cache-server server/*
./out/cache-server
docker pull abhi195/go-mem-cache
docker run --rm -i -p 8080:8080 abhi195/go-mem-cache
docker build -t go-mem-cache .
docker run --rm -i -p 8080:8080 go-mem-cache
Content type
Image
Digest
Size
6.2 MB
Last updated
almost 6 years ago
docker pull abhi195/go-mem-cache