mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-30 22:34:18 -05:00
parent
2d4bf70da0
commit
dbfc693aea
2 changed files with 14 additions and 1 deletions
|
@ -107,7 +107,11 @@ enabled using the `-cache` flag. It supports the following values:
|
||||||
variable be set.
|
variable be set.
|
||||||
- azure URL (e.g. `azure://container-name/`) - will cache images on
|
- azure URL (e.g. `azure://container-name/`) - will cache images on
|
||||||
Azure Storage. This requires `AZURESTORAGE_ACCOUNT_NAME` and
|
Azure Storage. This requires `AZURESTORAGE_ACCOUNT_NAME` and
|
||||||
`AZURESTORAGE_ACCESS_KEY` environmental variables set.
|
- redis URL (e.g. `redis://hostname/`) - will cache images on
|
||||||
|
the specified redis host. The full URL syntax is defined by the [redis URI
|
||||||
|
registration](https://www.iana.org/assignments/uri-schemes/prov/redis).
|
||||||
|
Rather than specify password in the URI, use the `REDIS_PASSWORD`
|
||||||
|
environment variable.
|
||||||
|
|
||||||
For example, to cache files on disk in the `/tmp/imageproxy` directory:
|
For example, to cache files on disk in the `/tmp/imageproxy` directory:
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,15 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/PaulARoy/azurestoragecache"
|
"github.com/PaulARoy/azurestoragecache"
|
||||||
"github.com/diegomarangoni/gcscache"
|
"github.com/diegomarangoni/gcscache"
|
||||||
|
"github.com/garyburd/redigo/redis"
|
||||||
"github.com/gregjones/httpcache"
|
"github.com/gregjones/httpcache"
|
||||||
"github.com/gregjones/httpcache/diskcache"
|
"github.com/gregjones/httpcache/diskcache"
|
||||||
|
rediscache "github.com/gregjones/httpcache/redis"
|
||||||
"github.com/peterbourgon/diskv"
|
"github.com/peterbourgon/diskv"
|
||||||
"sourcegraph.com/sourcegraph/s3cache"
|
"sourcegraph.com/sourcegraph/s3cache"
|
||||||
"willnorris.com/go/imageproxy"
|
"willnorris.com/go/imageproxy"
|
||||||
|
@ -132,6 +135,12 @@ func parseCache() (imageproxy.Cache, error) {
|
||||||
return gcscache.New(u.String()), nil
|
return gcscache.New(u.String()), nil
|
||||||
case "azure":
|
case "azure":
|
||||||
return azurestoragecache.New("", "", u.Host)
|
return azurestoragecache.New("", "", u.Host)
|
||||||
|
case "redis":
|
||||||
|
conn, err := redis.DialURL(u.String(), redis.DialPassword(os.Getenv("REDIS_PASSWORD")))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return rediscache.NewWithClient(conn), nil
|
||||||
case "file":
|
case "file":
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue