# Upstash

> Read and write key-value data in your Upstash Redis database: get a key's value, set a value (with an optional expiry), and delete a key.

App · Databases · 3 actions. Web page: https://docs.lodol.com/docs/integrations/upstash

## Actions

### Delete key

Delete a key from your Upstash Redis database. Returns deleted=false when the key did not exist.

**Inputs**

- Key (`key`, text, required): The Redis key to operate on, for example 'user:42:session'.

**Outputs**

- `deleted` (true/false): True when the key existed and was removed; false when it did not exist.
- `key` (text): The key targeted for deletion.

**Example output**

```json
{
  "deleted": true,
  "key": "greeting"
}
```

### Get value

Get the value stored at a key in your Upstash Redis database. Returns found=false when the key does not exist.

**Inputs**

- Key (`key`, text, required): The Redis key to operate on, for example 'user:42:session'.

**Outputs**

- `found` (true/false): True when the key exists.
- `key` (text): The key that was looked up.
- `value` (text): The stored value, or null when the key does not exist.

**Example output**

```json
{
  "found": true,
  "key": "greeting",
  "value": "Hello from Lodol"
}
```

### Set value

Store a value at a key in your Upstash Redis database, overwriting any existing value. Optionally have the key expire automatically after a number of seconds.

**Inputs**

- Key (`key`, text, required): The Redis key to operate on, for example 'user:42:session'.
- Value (`value`, text, required): The value to store for this key. Stored as text; convert numbers or JSON to text first if needed.
- Expire after (seconds) (`ttl_seconds`, number): Optional. Automatically delete the key this many seconds after it is set (Redis EX). Leave blank to keep it until it is deleted.

**Outputs**

- `key` (text): The key that was written.
- `success` (true/false): True when the value was stored.
- `ttl_seconds` (number): The expiry applied in seconds, or null when the key does not expire.

**Example output**

```json
{
  "key": "greeting",
  "success": true,
  "ttl_seconds": null
}
```
