> ## Documentation Index
> Fetch the complete documentation index at: https://docs.springwinter.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Provision a Valkey Cache in Your AWS Account

> Spin up a Redis-compatible Valkey cache on AWS ElastiCache inside your own account, reachable from your web servers and workers over TLS.

Springwinter provisions a Valkey cache directly in your AWS account using AWS ElastiCache. Valkey is an open-source, Redis-compatible key-value store, so any Redis client library works without modification. Your web servers and workers connect to it over TLS from within the same project's network — no public exposure, no password required.

## What Is Valkey?

Valkey is an open-source, community-maintained fork of Redis, licensed under BSD. It is wire-compatible with Redis clients and supports the same data structures: strings, hashes, lists, sets, sorted sets, and more. Springwinter provisions Valkey through AWS ElastiCache, so you get managed patching, automated failover, and CloudWatch metrics without running the infrastructure yourself.

## Create a Cache

<Steps>
  <Step title="Open your project">
    Navigate to your project in the Springwinter dashboard and click **Add resource**.
  </Step>

  <Step title="Select Cache">
    Choose **Cache** from the resource type list. You will be taken to the cache configuration form.
  </Step>

  <Step title="Choose a storage limit">
    Select the maximum memory allocation for the cache. Springwinter maps your selection to an appropriately sized ElastiCache node.
  </Step>

  <Step title="Create">
    Click **Create**. Springwinter provisions the ElastiCache cluster in your AWS account. The cache status changes to **Available** once provisioning is complete, typically within a few minutes.
  </Step>
</Steps>

## Connecting to the Cache

Once the cache is available, the connection endpoint appears in the **Connection** tab of the cache resource in your dashboard. The connection uses TLS on port 6379. No password is required — access is controlled at the network level, and only resources within the same project can reach the endpoint.

Use the connection string as an environment variable so your application code stays portable:

```bash theme={null}
REDIS_URL=rediss://<cache-endpoint>:6379
```

<Note>
  The `rediss://` scheme (double `s`) tells your Redis client to connect over TLS. No username or password is needed in the URL.
</Note>

<Tabs>
  <Tab title="Node.js (ioredis)">
    ```javascript theme={null}
    import Redis from "ioredis";

    const client = new Redis(process.env.REDIS_URL);

    await client.set("hello", "world");
    const value = await client.get("hello");
    console.log(value); // "world"
    ```
  </Tab>

  <Tab title="Python (redis-py)">
    ```python theme={null}
    import os
    import redis

    client = redis.from_url(os.environ["REDIS_URL"])

    client.set("hello", "world")
    value = client.get("hello")
    print(value)  # b"world"
    ```
  </Tab>

  <Tab title="Go (go-redis)">
    ```go theme={null}
    import (
        "context"
        "fmt"
        "os"

        "github.com/redis/go-redis/v9"
    )

    opt, _ := redis.ParseURL(os.Getenv("REDIS_URL"))
    client := redis.NewClient(opt)

    ctx := context.Background()
    client.Set(ctx, "hello", "world", 0)
    val, _ := client.Get(ctx, "hello").Result()
    fmt.Println(val) // "world"
    ```
  </Tab>
</Tabs>

<Note>
  The cache is private to your AWS account's network. It is not reachable from the public internet — only resources within the same project can connect.
</Note>

## API Reference

### Create a Cache

```http theme={null}
POST /api/projects/{project_id}/redis
Authorization: Bearer <token>
Content-Type: application/json
```

```json theme={null}
{
  "name": "my-cache",
  "storage_limit": "1gb"
}
```

### Get a Cache

```http theme={null}
GET /api/projects/{project_id}/redis/{id}
Authorization: Bearer <token>
```

### Update the Storage Limit

Change the memory allocation of an existing cache by sending a PATCH request:

```http theme={null}
PATCH /api/projects/{project_id}/redis/{id}
Authorization: Bearer <token>
Content-Type: application/json
```

```json theme={null}
{
  "storage_limit": "4gb"
}
```

Springwinter updates the ElastiCache node type. Expect a brief interruption while the node scales.

## Metrics

CloudWatch metrics for your cache — including memory usage, connection count, and cache hit rate — are available from the **Metrics** tab in the dashboard or via the API:

```http theme={null}
GET /api/projects/{project_id}/redis/{id}/metrics
Authorization: Bearer <token>
```

## Cost Estimate

Retrieve the current ElastiCache cost estimate and monthly run rate:

```http theme={null}
GET /api/projects/{project_id}/redis/{id}/cost
Authorization: Bearer <token>
```

## Delete a Cache

To remove the ElastiCache cluster from your AWS account:

```http theme={null}
DELETE /api/projects/{project_id}/redis/{id}
Authorization: Bearer <token>
```

<Warning>
  Deleting a cache is permanent. All data stored in the cache is lost immediately. Update any environment variables that reference the cache endpoint before deleting, to avoid errors in your running services.
</Warning>
