# Interface IDataStore (1.73.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.73.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.IDataStore)
- [1.69.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.69.0/Google.Apis.Util.Store.IDataStore)
- [1.68.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Util.Store.IDataStore)
- [1.60.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Util.Store.IDataStore)
- [1.59.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Util.Store.IDataStore)
- [1.55.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Util.Store.IDataStore)
- [1.50.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Util.Store.IDataStore)

    public interface IDataStore

Stores and manages data objects, where the key is a string and the value is an object.
The store will use [Instance](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Json.NewtonsoftJsonSerializer#Google_Apis_Json_NewtonsoftJsonSerializer_Instance) for serialization.


`null` keys are not allowed.

<br />

## Namespace

[Google.Apis.Util.Store](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store)

## Assembly

Google.Apis.Core.dll

## Methods

### ClearAsync()

    Task ClearAsync()

Asynchronously clears all values in the data store.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` |   |

### DeleteAsync\<T\>(string)

    Task DeleteAsync<T>(string key)

Asynchronously deletes the given key. The type is provided here as well because the "real" saved key should
contain type information as well, so the data store will be able to store the same key for different types.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `https://learn.microsoft.com/dotnet/api/system.string` The key to delete. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` |   |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type to delete from the data store. |

### GetAsync\<T\>(string)

    Task<T> GetAsync<T>(string key)

Asynchronously returns the stored value for the given key or `null` if not found.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `https://learn.microsoft.com/dotnet/api/system.string` The key to retrieve its value. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1` | The stored object deserialized using [Instance](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Json.NewtonsoftJsonSerializer#Google_Apis_Json_NewtonsoftJsonSerializer_Instance). |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type to retrieve from the data store. |

### StoreAsync\<T\>(string, T)

    Task StoreAsync<T>(string key, T value)

Asynchronously stores the given value for the given key (replacing any existing value).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `https://learn.microsoft.com/dotnet/api/system.string` The key. |
| `value` | `T` The value to store. Will be serialized using [Instance](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Json.NewtonsoftJsonSerializer#Google_Apis_Json_NewtonsoftJsonSerializer_Instance). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` |   |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type to store in the data store. |

## Extension Method

[Utilities.ThrowIfNull\<T\>(T, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)