Class AppSettingStore
SQL Server app setting store implementation. Manages persistence and retrieval of application settings from the database with caching support.
Implements
Inherited Members
Namespace: DataWeb.Setting.SqlServer
Assembly: DataWeb.Data.SqlServer.dll
Syntax
public class AppSettingStore : IAppSettingStore
Constructors
AppSettingStore(ISqlHelper, ICacheService)
SQL Server app setting store implementation. Manages persistence and retrieval of application settings from the database with caching support.
Declaration
public AppSettingStore(ISqlHelper sqlHelper, ICacheService cacheService)
Parameters
| Type | Name | Description |
|---|---|---|
| ISqlHelper | sqlHelper | |
| ICacheService | cacheService |
Properties
Name
Gets the name of the store.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
ExistsAsync(string, CancellationToken)
Checks whether a setting with the specified name exists in the database.
Declaration
public Task<bool> ExistsAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Setting name. Cannot be null or empty. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If name is null or empty. |
GetSettingAsync(string, CancellationToken)
Retrieves a single setting value by name.
Declaration
public Task<string> GetSettingAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Setting name. Cannot be null or empty. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<string> | The setting value, or null if the setting does not exist. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If name is null or empty. |
GetSettingsAsync(CancellationToken)
Retrieves all application settings from the database.
Declaration
public Task<IEnumerable<AppSetting>> GetSettingsAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<AppSetting>> | Collection of all application settings. |
GetSettingsCachedAsync(CancellationToken)
Retrieves all application settings from cache, or from the database if not cached.
Declaration
public Task<IEnumerable<AppSetting>> GetSettingsCachedAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<AppSetting>> | Collection of all application settings. |
RemoveAsync(string, CancellationToken)
Removes an application setting from the database, then invalidates the cache.
Declaration
public Task RemoveAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Setting name. Cannot be null or empty. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If name is null or empty. |
SetAsync(string, string, CancellationToken)
Saves or updates an application setting, then invalidates the cache.
Declaration
public Task SetAsync(string name, string value, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Setting name. Cannot be null or empty. |
| string | value | Setting value. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If name is null or empty. |