This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
|||||||
_ "image/png"
|
_ "image/png"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
_ "golang.org/x/image/webp"
|
_ "golang.org/x/image/webp"
|
||||||
|
|
||||||
@@ -98,7 +97,7 @@ func (s *Service) GetImage(ctx context.Context, uid string, options Options) (im
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = s.cache.Do(ctx, s.cache.B().Set().Key("img:"+hash).Value(valkey.BinaryString(outBuff.Bytes())).Ex(time.Hour*48).Build()).Error(); err == nil {
|
if err = s.cache.Do(ctx, s.cache.B().Set().Key("img:"+hash).Value(valkey.BinaryString(outBuff.Bytes())).Ex(s.cfg.CacheLifetime).Build()).Error(); err == nil {
|
||||||
return outBuff, "image/jpeg", err
|
return outBuff, "image/jpeg", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
func Default() Cfg {
|
func Default() Cfg {
|
||||||
return Cfg{
|
return Cfg{
|
||||||
Image: &ImageConfig{
|
Image: &ImageConfig{
|
||||||
Concurency: 10,
|
Concurency: 10,
|
||||||
Quality: 80,
|
Quality: 80,
|
||||||
|
CacheLifetime: time.Hour * 24 * 31,
|
||||||
},
|
},
|
||||||
Tracking: &UmamiConfig{
|
Tracking: &UmamiConfig{
|
||||||
ScriptSrc: "https://umami.schreifuchs.ch/script.js",
|
ScriptSrc: "https://umami.schreifuchs.ch/script.js",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package config
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/sethvargo/go-envconfig"
|
"github.com/sethvargo/go-envconfig"
|
||||||
)
|
)
|
||||||
@@ -36,8 +37,9 @@ type ValkeyConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImageConfig struct {
|
type ImageConfig struct {
|
||||||
Concurency int64 `env:"CONCURENCY"`
|
Concurency int64 `env:"CONCURENCY"`
|
||||||
Quality int `env:"QUALITY"`
|
Quality int `env:"QUALITY"`
|
||||||
|
CacheLifetime time.Duration `env:"CACHE_LIFETIME"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UmamiConfig struct {
|
type UmamiConfig struct {
|
||||||
@@ -54,6 +56,7 @@ func Read(ctx context.Context) (cfg Cfg, err error) {
|
|||||||
// overridden.
|
// overridden.
|
||||||
DefaultDelimiter: ";",
|
DefaultDelimiter: ";",
|
||||||
DefaultSeparator: "@",
|
DefaultSeparator: "@",
|
||||||
|
DefaultOverwrite: true,
|
||||||
|
|
||||||
Lookuper: envconfig.MultiLookuper(secretLookuper(), envconfig.OsLookuper()),
|
Lookuper: envconfig.MultiLookuper(secretLookuper(), envconfig.OsLookuper()),
|
||||||
})
|
})
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user