---
title: KVStore
url: https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/kv_store/class.KVStore/
---

**Kind:** Class  
**Module:** [kv_store](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/kv_store/)  
**Package:** compute-sdk-cpp 0.7.0  
**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L285

Include `fastly/kv_store.h` to use this class.

## Methods

### build_erase

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L319

```cpp
EraseBuilder fastly::kv_store::KVStore::build_erase() const
```

Create a buildable erase request for the KV Store. When the desired configuration has been set, execute the erase and wait for the response.

**Returns**

`EraseBuilder`

### build_insert

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L307

```cpp
InsertBuilder fastly::kv_store::KVStore::build_insert() const
```

Create a buildable insert request for the KV Store. When the desired configuration has been set, execute the insert and wait for the response.

**Returns**

`InsertBuilder`

### build_list

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L330

```cpp
ListBuilder fastly::kv_store::KVStore::build_list() const
```

Create a buildable list request for the KV Store. When the desired configuration has been set, execute the list and wait for the response.

**Returns**

`ListBuilder`

### build_lookup

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L292

```cpp
LookupBuilder fastly::kv_store::KVStore::build_lookup() const
```

**Returns**

`LookupBuilder`

### erase

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L314

```cpp
expected fastly::kv_store::KVStore::erase(std::string_view key) const
```

Erase a value in the KV Store.

**Parameters**

- `key`: `std::string_view`

**Returns**

`expected`

### insert

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L302

```cpp
expected fastly::kv_store::KVStore::insert(std::string_view key, Body value) const
```

Insert a value into the KV Store.

If the store already contained a value for this key, it will be overwritten. Returns an error if the value cannot be inserted.

**Parameters**

- `key`: `std::string_view`
- `value`: `Body`

**Returns**

`expected`

### list

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L325

```cpp
expected<ListPage> fastly::kv_store::KVStore::list() const
```

List keys in the KV Store.

**Returns**

`expected<ListPage>`

### lookup

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L291

```cpp
expected<LookupResponse> fastly::kv_store::KVStore::lookup(std::string_view key) const
```

**Parameters**

- `key`: `std::string_view`

**Returns**

`expected<LookupResponse>`

### open

**Flags:** static  
**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L290

```cpp
static expected<std::optional<KVStore>> fastly::kv_store::KVStore::open(std::string_view name)
```

Opens a key-value store with the given name.

Returns an error if the store cannot be opened.

**Parameters**

- `name`: `std::string_view`

**Returns**

`expected<std::optional<KVStore>>`

### pending_erase_wait

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L322

```cpp
expected fastly::kv_store::KVStore::pending_erase_wait(PendingEraseHandle pending_erase_handle) const
```

Erase a value in the KV Store.

**Parameters**

- `pending_erase_handle`: `PendingEraseHandle`

**Returns**

`expected`

### pending_insert_wait

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L311

```cpp
expected fastly::kv_store::KVStore::pending_insert_wait(PendingInsertHandle pending_insert_handle) const
```

Insert a value in the KV Store.

**Parameters**

- `pending_insert_handle`: `PendingInsertHandle`

**Returns**

`expected`

### pending_list_wait

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L334

```cpp
expected<ListPage> fastly::kv_store::KVStore::pending_list_wait(PendingListHandle pending_request_handle) const
```

Wait on a pending list operation.

**Parameters**

- `pending_request_handle`: `PendingListHandle`

**Returns**

`expected<ListPage>`

### pending_lookup_wait

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/kv_store.h#L296

```cpp
expected<LookupResponse> fastly::kv_store::KVStore::pending_lookup_wait(PendingLookupHandle pending_request_handle) const
```

Look up a value in the KV Store.

**Parameters**

- `pending_request_handle`: `PendingLookupHandle`

**Returns**

`expected<LookupResponse>`
