# Key-value store

## Coherence.Play.DB

This class provides the methods to set, get and unset key-value pairs. This is executed within the context of the currently logged in player.

```csharp
public static class KvStore
{
    // Sets a value
    // key: lowercase letters, numbers, underscore, dash
    // val: any string (null is not allowed)
    public static void Set(string key, string val)
    
    // Gets a value
    // key: lowercase letters, numbers, underscore, dash
    public static string Get(string key)
    
    // Unsets a value, removing it from the store
    // key: lowercase letters, numbers, underscore, dash
    public static void Unset(string key)
}
```

## Example

```csharp
Play.KvStore.Set("foo", "1");

var foo = Play.KvStore.Get("foo");
Debug.Log(string.Format("foo={0}", foo)); // foo=1

Play.KvStore.Unset("foo");
```

## Limitations

**Size**: there are no limits to the number of stored key/values as long as the total size is less than 256kb.

**Requests**: Set/Get/Unset can be called unlimited amount of times but the execution may be throttled.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/0.5.2/api-reference/cloud-api/key-value-store.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
