2.4 KiB
2.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-17T15:54:56.419164+00:00 | zai-org/GLM-5-FP8 | 1 | 13a82f958bbaccd7 |
Documentation: SettingsDB Module
1. Purpose
This module provides a thread-safe, database-backed key-value store for application settings. It implements a singleton pattern (SettingsDB) that manages in-memory cached Setting objects, with concrete implementations like GlobalSetting for system-wide configuration. The module abstracts database operations for persisting and retrieving settings via SQL stored procedures, supporting both string and boolean values with automatic default value initialization.
2. Public Interface
SettingsDB (Concrete Class)
A singleton class that serves as the primary entry point for managing global settings.
| Method | Signature | Description |
|---|---|---|
GetGlobalValue |
public static string GetGlobalValue(string id, string defaultValue) |
Retrieves a global setting by ID. Creates a new GlobalSetting with the provided default value if the ID doesn't exist in the cache. Returns the cached PropertyValue. |
GetGlobalValueBool |
public static bool GetGlobalValueBool(string id, bool defaultValue) |
Retrieves a global setting as a boolean. Parses the stored string value; returns defaultValue if parsing fails. |
SetGlobalValue |
public static void SetGlobalValue(string id, string value) |
Stores a global property in the database. Creates a new GlobalSetting if the ID doesn't exist; otherwise updates the existing value via SetValue(). |
SetGlobalValueBoolean |
public static void SetGlobalValueBoolean(string id, bool value) |
Stores a boolean global property. Converts the bool to string using InvariantCulture before persisting. |
Setting (Abstract Base Class)
Base class for all setting types, handling database persistence.
| Member | Signature | Description |
|---|---|---|
PropertyId |
public string PropertyId => _propertyId |
Read-only string identifier for the property. |
PropertyValue |
public string PropertyValue => _propertyValue |
Read-only string value of the property. |
UserId |
`public string UserId |