feat: Add Redis upload cache for multi-replica deployments (#5724)

This commit is contained in:
Arran authored and GitHub committed 2026-02-01 17:08:40 +01:00
1 parent b8da36e630
commit 08d7a1504c
9 files changed
+262 -55

No files matched your search

+9 -1
View File
@@ -46,6 +46,7 @@ var (
"disable-type-detection-by-header": "disableTypeDetectionByHeader",
"img-processors": "imageProcessors",
"cache-dir": "cacheDir",
"redis-cache-url": "redisCacheUrl",
"token-expiration-time": "tokenExpirationTime",
"baseurl": "baseURL",
}
@@ -88,6 +89,7 @@ func init() {
flags.String("password", "", "hashed password for the first user when using quick setup")
flags.Uint32("socketPerm", 0666, "unix socket file permissions")
flags.String("cacheDir", "", "file cache directory (disabled if empty)")
flags.String("redisCacheUrl", "", "redis cache URL (for multi-instance deployments), e.g. redis://user:pass@host:port")
flags.Int("imageProcessors", 4, "image processors count")
addServerFlags(flags)
}
@@ -176,6 +178,12 @@ user created with the credentials from options "username" and "password".`,
fileCache = diskcache.New(afero.NewOsFs(), cacheDir)
}
redisCacheURL := v.GetString("redisCacheUrl")
uploadCache, err := fbhttp.NewUploadCache(redisCacheURL)
if err != nil {
return fmt.Errorf("failed to initialize upload cache: %w", err)
}
server, err := getServerSettings(v, st.Storage)
if err != nil {
return err
@@ -227,7 +235,7 @@ user created with the credentials from options "username" and "password".`,
panic(err)
}
handler, err := fbhttp.NewHandler(imageService, fileCache, st.Storage, server, assetsFs)
handler, err := fbhttp.NewHandler(imageService, fileCache, uploadCache, st.Storage, server, assetsFs)
if err != nil {
return err
}