Use WebDomain as fallback redis prefix if none is set explicitly
This commit is contained in:
parent
a88612bc18
commit
242d01583f
2 changed files with 11 additions and 7 deletions
|
@ -70,16 +70,18 @@ public static class ServiceExtensions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddRedis(this IServiceCollection services, IConfiguration configuration) {
|
public static void AddRedis(this IServiceCollection services, IConfiguration configuration) {
|
||||||
var config = configuration.GetSection("Redis").Get<Config.RedisSection>();
|
var instance = configuration.GetSection("Instance").Get<Config.InstanceSection>();
|
||||||
if (config == null) throw new Exception("Failed to initialize redis: Failed to load configuration");
|
var redis = configuration.GetSection("Redis").Get<Config.RedisSection>();
|
||||||
|
if (redis == null || instance == null)
|
||||||
|
throw new Exception("Failed to initialize redis: Failed to load configuration");
|
||||||
services.AddStackExchangeRedisCache(options => {
|
services.AddStackExchangeRedisCache(options => {
|
||||||
options.InstanceName = config.Prefix + ":";
|
options.InstanceName = redis.Prefix ?? instance.WebDomain + ":";
|
||||||
options.ConfigurationOptions = new ConfigurationOptions {
|
options.ConfigurationOptions = new ConfigurationOptions {
|
||||||
User = config.Username,
|
User = redis.Username,
|
||||||
Password = config.Password,
|
Password = redis.Password,
|
||||||
DefaultDatabase = config.Database,
|
DefaultDatabase = redis.Database,
|
||||||
EndPoints = new EndPointCollection {
|
EndPoints = new EndPointCollection {
|
||||||
{ config.Host, config.Port }
|
{ redis.Host, redis.Port }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
[Instance]
|
[Instance]
|
||||||
ListenPort = 3000
|
ListenPort = 3000
|
||||||
|
|
||||||
|
;; Caution: changing these settings after initial setup *will* break federation
|
||||||
WebDomain = shrimp.example.org
|
WebDomain = shrimp.example.org
|
||||||
AccountDomain = example.org
|
AccountDomain = example.org
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue