go-echo-cache, is a server-side HTTP cache middleware designed to work with Echo framework.
The in-memory cache is managed by freecache, a cache library with zero GC overhead and high concurrent performance.
The recommended way to install go-echo-cache is:
go get -u github.com/gitsight/go-echo-cache
A basic example that mimics the standard git clone
command
package main
import (
"net/http"
"time"
"github.com/coocood/freecache"
cache "github.com/gitsight/go-echo-cache"
"github.com/labstack/echo/v4"
)
func main() {
c := freecache.NewCache(1024 * 1024) // Pre-allocated cache of 1Mb)
e := echo.New()
e.Use(cache.New(&cache.Config{}, c))
e.GET("/", func(c echo.Context) error {
c.String(http.StatusOK, time.Now().String())
return nil
})
e.Start(":8080")
}
Apache License Version 2.0, see LICENSE