Commands: SetKeyAsync

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

Syntax

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

Return Value
Task A 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 { /* ... */ });