Skip to main content

Commands: SetKeyAsync

Syntax

#Commands: SetKeyAsync

SetKeyAsync is used to store any object as a configuration item under the specified key.

Task SetKeyAsync<T>(string key, T data);
Parameters
keystringThe configuration name
dataTThe stored object that will be serialized to JSON and saved as a configuration.

Return Value
TaskA task that represents the asynchronous set operation

Example

Let's assume that we need to store file descriptions for some files but we don't want to add such information to their metadata. The file description is represented by the FileDescription class:

public class FileDescription
{
/* ... */
}

We can achieve that simply by setting such an object under the selected key:

await store
.AsyncFilesCommands
.Configuration
.SetKeyAsync("descriptions/intro.avi", new FileDescription { /* ... */ });