mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-16 21:56:43 -05:00
add cacheSize flag to cmd/imageproxy
httpcache hardcodes the cache size to 100MB. We are still using that as the default value, but it can now be overridden. refs #9
This commit is contained in:
parent
7994cb2cf6
commit
e0a9588607
1 changed files with 7 additions and 1 deletions
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
"github.com/gregjones/httpcache"
|
||||
"github.com/gregjones/httpcache/diskcache"
|
||||
"github.com/peterbourgon/diskv"
|
||||
"willnorris.com/go/imageproxy"
|
||||
)
|
||||
|
||||
|
@ -39,6 +40,7 @@ var (
|
|||
var addr = flag.String("addr", "localhost:8080", "TCP address to listen on")
|
||||
var whitelist = flag.String("whitelist", "", "comma separated list of allowed remote hosts")
|
||||
var cacheDir = flag.String("cacheDir", "", "directory to use for file cache")
|
||||
var cacheSize = flag.Uint64("cacheSize", 100, "maximum size of file cache (in MB)")
|
||||
var version = flag.Bool("version", false, "print version information")
|
||||
|
||||
func main() {
|
||||
|
@ -51,7 +53,11 @@ func main() {
|
|||
|
||||
var c httpcache.Cache
|
||||
if *cacheDir != "" {
|
||||
c = diskcache.New(*cacheDir)
|
||||
d := diskv.New(diskv.Options{
|
||||
BasePath: *cacheDir,
|
||||
CacheSizeMax: *cacheSize * 1024 * 1024,
|
||||
})
|
||||
c = diskcache.NewWithDiskv(d)
|
||||
} else {
|
||||
c = httpcache.NewMemoryCache()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue