# Work with key-value data

Choose a key-value interface, name keys consistently, and understand expiration and coordination boundaries.

Source: https://particledb.ai/guides/key-value/

Use key-value data for direct lookups, counters and expiration. Choose either the supported SQL functions or an existing Redis client, based on your application.

## Read and write a value from SQL

```sql
SELECT KV_SET('docs:session:1', 'active');
SELECT KV_GET('docs:session:1') AS status;
```

The read returns `active`.

## Name keys consistently

Use an application and account prefix, such as `app:account:record`. Keep credentials and private data out of key names, which may appear in logs or diagnostics.

## Expiration and data structures

Redis-compatible clients expose strings, lists, sets and other supported structures. See [Redis compatibility](/redis/overview/) and the [command reference](/connectivity/redis-commands/) for exact syntax and limits.

## Coordination boundaries

A list operation is not automatically a durable workflow scheduler. Check blocking behavior, acknowledgements, retry handling and the atomicity of each operation before building a worker queue. Do not assume a SQL transaction includes commands sent over a separate client connection.

## Next steps

[Redis compatibility](/redis/overview/) · [Agents and workflows](/guides/agents-and-workflows/)
