'Missing key']); try { $pdo->beginTransaction(); $updated = $pdo->prepare("UPDATE config SET value = ?, updated_at = EXTRACT(EPOCH FROM NOW())::BIGINT WHERE key = ?") ->execute([$value, $key]); if (!$updated) { throw new RuntimeException("Failed to update $key"); } // The caching daemon polls this generation value and reloads config // independently of whether the relay's main process is restarted. if (in_array($key, [ 'caching_backfill_enabled', 'caching_inbox_enabled', 'caching_live_enabled', 'caching_live_strategy', 'caching_live_kinds', 'caching_live_since_seconds', 'caching_live_limit', 'caching_backfill_page_size', 'caching_backfill_tick_interval_ms' ], true)) { $pdo->exec("UPDATE config SET value = (COALESCE(value::int, 0) + 1)::text, updated_at = EXTRACT(EPOCH FROM NOW())::BIGINT WHERE key = 'caching_config_generation'"); } $pdo->commit(); json_response(['message' => "Updated $key"]); } catch (Throwable $e) { if ($pdo->inTransaction()) $pdo->rollBack(); json_response(['error' => $e->getMessage()], 500); } } $rows = $pdo->query("SELECT key, value FROM config ORDER BY key")->fetchAll(); json_response(['config' => $rows]);