mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 00:33:17 +00:00
Update ConfigCacheService, fix database race condition and fallback to file config and enable by default
This commit is contained in:
parent
cbf996c9b6
commit
60a62b59c9
3 changed files with 133 additions and 129 deletions
|
@ -67,7 +67,7 @@ ADMIN_DOMAIN="${APP_DOMAIN}"
|
||||||
# @default "false"
|
# @default "false"
|
||||||
# @see https://docs.pixelfed.org/technical-documentation/config/#config_cache
|
# @see https://docs.pixelfed.org/technical-documentation/config/#config_cache
|
||||||
# @dottie/validate required,boolean
|
# @dottie/validate required,boolean
|
||||||
ENABLE_CONFIG_CACHE="false"
|
ENABLE_CONFIG_CACHE="true"
|
||||||
|
|
||||||
# Enable/disable new local account registrations.
|
# Enable/disable new local account registrations.
|
||||||
#
|
#
|
||||||
|
|
|
@ -8,7 +8,7 @@ OPEN_REGISTRATION="false"
|
||||||
ENFORCE_EMAIL_VERIFICATION="false"
|
ENFORCE_EMAIL_VERIFICATION="false"
|
||||||
PF_MAX_USERS="1000"
|
PF_MAX_USERS="1000"
|
||||||
OAUTH_ENABLED="true"
|
OAUTH_ENABLED="true"
|
||||||
ENABLE_CONFIG_CACHE=false
|
ENABLE_CONFIG_CACHE=true
|
||||||
|
|
||||||
# Media Configuration
|
# Media Configuration
|
||||||
PF_OPTIMIZE_IMAGES="true"
|
PF_OPTIMIZE_IMAGES="true"
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Services;
|
||||||
|
|
||||||
use App\Models\ConfigCache as ConfigCacheModel;
|
use App\Models\ConfigCache as ConfigCacheModel;
|
||||||
use Cache;
|
use Cache;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
|
||||||
class ConfigCacheService
|
class ConfigCacheService
|
||||||
{
|
{
|
||||||
|
@ -25,8 +26,8 @@ class ConfigCacheService
|
||||||
return config($key);
|
return config($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
return Cache::remember($cacheKey, $ttl, function () use ($key) {
|
return Cache::remember($cacheKey, $ttl, function () use ($key) {
|
||||||
|
|
||||||
$allowed = [
|
$allowed = [
|
||||||
'app.name',
|
'app.name',
|
||||||
'app.short_description',
|
'app.short_description',
|
||||||
|
@ -175,6 +176,9 @@ class ConfigCacheService
|
||||||
|
|
||||||
return $v;
|
return $v;
|
||||||
});
|
});
|
||||||
|
} catch (Exception | QueryException $e) {
|
||||||
|
return config($key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function put($key, $val)
|
public static function put($key, $val)
|
||||||
|
|
Loading…
Reference in a new issue