0
Fork 0
mirror of https://github.com/willnorris/imageproxy.git synced 2024-12-16 21:56:43 -05:00

allow specifying multiple cache with spaces

this is necessary for the new environment variable support for config
values.  I don't love that allowHosts is comma separated and cache is
space separated :(
This commit is contained in:
Will Norris 2019-06-09 22:09:55 +00:00
parent d8ed21c0f4
commit fe437a0b8c
2 changed files with 15 additions and 13 deletions

View file

@ -160,11 +160,11 @@ version.
[codercat URL]: http://localhost:8080/500/https://octodex.github.com/images/codercat.jpg
If the `-cache` flag is specified multiple times, multiple caches will be
created in a [tiered fashion][]. Typically this is used to put a smaller and
faster in-memory cache in front of a larger but slower on-disk cache. For
example, the following will first check an in-memory cache for an image,
followed by a gcs bucket:
Multiple caches can be specified by separating them by spaces or by repeating
the `-cache` flag multiple times. The caches will be created in a [tiered
fashion][]. Typically this is used to put a smaller and faster in-memory cache
in front of a larger but slower on-disk cache. For example, the following will
first check an in-memory cache for an image, followed by a gcs bucket:
imageproxy -cache memory -cache gcs://my-bucket/

View file

@ -122,15 +122,17 @@ func (tc *tieredCache) String() string {
}
func (tc *tieredCache) Set(value string) error {
c, err := parseCache(value)
if err != nil {
return err
}
for _, v := range strings.Fields(value) {
c, err := parseCache(v)
if err != nil {
return err
}
if tc.Cache == nil {
tc.Cache = c
} else {
tc.Cache = twotier.New(tc.Cache, c)
if tc.Cache == nil {
tc.Cache = c
} else {
tc.Cache = twotier.New(tc.Cache, c)
}
}
return nil
}