# kv.entry.expire

Gives a key-value entry a new lifetime without changing its value

# kv.entry.expire

```
kv.entry.expire --key TEXT [--ttl DURATION] [--durable] → entry
```

Gives a key-value entry a new lifetime without changing its value. Give the entry `--key` a new lifetime `--ttl` (a duration such as 30m, counted from now) without changing its value; without `--ttl` the expiry is removed and it lives until deleted. `--durable` for the disk-backed store. Adds `entry: { key, ttl?, updated }` and keeps the rest of the payload; a key that is not there answers `updated: false`.

## Flags

- `--key` (required): The entry whose lifetime changes. Usually a {{ }} expression.
- `--ttl`: The new lifetime from now, e.g. 30m or 1d. Omitted: the expiry is removed.
- `--durable`: Use the disk-backed store, which survives a restart. Default: the in-memory one.

## Examples

### Keep an active session alive

```
| kv.entry.expire --key "session:{{ $trigger.auth.sub }}" --ttl 30m
```

It answers:

```json
{
  "entry": {
    "key": "session:u_1",
    "ttl": "1800s",
    "updated": true
  }
}
```
