Interface IKeyValueService
Manages the simplified key/value store.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IKeyValueService
Methods
View SourceFindByKeyPrefix(string)
Returns key/value pairs for all keys with the specified prefix.
Declaration
IReadOnlyDictionary<string, string?>? FindByKeyPrefix(string keyPrefix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keyPrefix |
Returns
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, string> |
GetValue(string)
Gets a value.
Declaration
string? GetValue(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key |
Returns
| Type | Description |
|---|---|
| string |
Remarks
Returns null if no value was found for the key.
SetValue(string, string)
Sets a value.
Declaration
void SetValue(string key, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | |
| string | value |
SetValue(string, string, string)
Sets a value.
Declaration
void SetValue(string key, string originValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | |
| string | originValue | |
| string | newValue |
Remarks
Sets the value to newValue if the value is originValue,
and returns true; otherwise throws an exception. In other words, ensures that the value has not changed
before setting it.
TrySetValue(string, string, string)
Tries to set a value.
Declaration
bool TrySetValue(string key, string originValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | |
| string | originValue | |
| string | newValue |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
Sets the value to newValue if the value is originValue,
and returns true; otherwise returns false. In other words, ensures that the value has not changed
before setting it.