add basic caching support

includes two implementations, a no-op NopCache and an in-memory
MemoryCache.
This commit is contained in:
Will Norris 2013-12-04 02:55:56 -08:00
parent a8fb3012bd
commit 95fdd8b79f
6 changed files with 167 additions and 12 deletions

View file

@ -1,16 +1,26 @@
package main
import (
"flag"
"fmt"
"log"
"net/http"
"github.com/willnorris/go-imageproxy/cache"
"github.com/willnorris/go-imageproxy/proxy"
)
var port = flag.Int("port", 8080, "port to listen on")
func main() {
flag.Parse()
fmt.Printf("go-imageproxy listening on port %d\n", *port)
p := proxy.NewProxy(nil)
p.Cache = cache.NewMemoryCache()
server := &http.Server{
Addr: ":8080",
Addr: fmt.Sprintf(":%d", *port),
Handler: p,
}
err := server.ListenAndServe()