mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-30 22:34:18 -05:00
using s3 as caching store
This commit is contained in:
parent
f67209437a
commit
ec96fcbc90
2 changed files with 8 additions and 0 deletions
|
@ -150,6 +150,10 @@ enabled using the `-cache` flag. It supports the following values:
|
||||||
available memory and is not recommended for production systems)
|
available memory and is not recommended for production systems)
|
||||||
- directory on local disk (e.g. `/tmp/imageproxy`) - will cache images
|
- directory on local disk (e.g. `/tmp/imageproxy`) - will cache images
|
||||||
on disk, limited to the size specified in the `-cacheSize` flag.
|
on disk, limited to the size specified in the `-cacheSize` flag.
|
||||||
|
- s3 URL (e.g. `s3://s3-us-west-2.amazonaws.com/my-bucket`) - will cache
|
||||||
|
images on Amazon S3. This requires either an IAM role and instance profile
|
||||||
|
with access to your your bucket or `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY`
|
||||||
|
environmental parameters set.
|
||||||
|
|
||||||
For example, to cache files on disk, allowing up to 100MB of space:
|
For example, to cache files on disk, allowing up to 100MB of space:
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/gregjones/httpcache"
|
"github.com/gregjones/httpcache"
|
||||||
"github.com/gregjones/httpcache/diskcache"
|
"github.com/gregjones/httpcache/diskcache"
|
||||||
"github.com/peterbourgon/diskv"
|
"github.com/peterbourgon/diskv"
|
||||||
|
"sourcegraph.com/sourcegraph/s3cache"
|
||||||
"willnorris.com/go/imageproxy"
|
"willnorris.com/go/imageproxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -120,6 +121,9 @@ func parseCache() (imageproxy.Cache, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch u.Scheme {
|
switch u.Scheme {
|
||||||
|
case "s3":
|
||||||
|
u.Scheme = "https"
|
||||||
|
return s3cache.New(u.String()), nil
|
||||||
case "file":
|
case "file":
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue