Interface IKeyValueService
Manages the simplified key/value store.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IKeyValueServiceMethods
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 | 
|---|---|---|
| System.String | keyPrefix | 
Returns
| Type | Description | 
|---|---|
| System.Nullable<IReadOnlyDictionary<System.String, System.String>> | 
GetValue(String)
Gets a value.
Declaration
string GetValue(string key)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | key | 
Returns
| Type | Description | 
|---|---|
| System.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 | 
|---|---|---|
| System.String | key | |
| System.String | value | 
SetValue(String, String, String)
Sets a value.
Declaration
void SetValue(string key, string originValue, string newValue)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | key | |
| System.String | originValue | |
| System.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 | 
|---|---|---|
| System.String | key | |
| System.String | originValue | |
| System.String | newValue | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
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.