# Dragonfly (/docs/databases-and-storage/dragonfly)



[Dragonfly](https://github.com/dragonflydb/dragonfly) is a modern, Redis-compatible in-memory datastore. Use it for caching, session storage, queues, and any workload where you'd normally use Redis.

## Create a Dragonfly Service [#create-a-dragonfly-service]

1. Click **Add Service** in your project
2. Select **Database**
3. Choose **Dragonfly**
4. Select a storage size
5. Enter a name (e.g., `dragonfly-cache`, `dragonfly-sessions`)
6. Click **Create**

Rock8Cloud provisions the instance with networking handled automatically.

***

## Environment Variables [#environment-variables]

After creation, Rock8Cloud exposes these variables for your application to connect:

| Variable | Description        | Example            |
| -------- | ------------------ | ------------------ |
| `HOST`   | Dragonfly hostname | *(auto-generated)* |
| `PORT`   | Dragonfly port     | `6379`             |

### Linking to Your Application [#linking-to-your-application]

1. Go to your application service → **Deployments** → **Env Vars**
2. Add the Dragonfly variables using the names expected by your framework

**Common framework patterns:**

```bash
# Node.js (ioredis / redis)
REDIS_HOST=<HOST>
REDIS_PORT=<PORT>
# or
REDIS_URL=redis://<HOST>:<PORT>

# Python (redis-py)
REDIS_HOST=<HOST>
REDIS_PORT=<PORT>

# Rails (Sidekiq, Action Cable)
REDIS_URL=redis://<HOST>:<PORT>/0
```

After saving, your application automatically redeploys with the new configuration.

***

## Logs and History [#logs-and-history]

A Dragonfly service has three tabs of its own:

* **Logs** - live runtime logs streamed from the database pods. Click **Start Logs** to stream, scroll up to load older lines, and use copy or export to pull them out
* **History** - every deployment of this service with its status, version, storage size, and replica count. The current one is highlighted at the top
* **Resources** - replicas and the CPU / memory allocation drawn from your plan's pool, with the pool meters and a shortcut to buy more. Changes apply right away. Dragonfly keeps its data in memory, so a memory change restarts the datastore and clears it - the page asks you to confirm

***

## Features [#features]

* **Redis-compatible** - drop-in replacement for Redis, works with any Redis client library
* **High performance** - multi-threaded architecture, significantly faster than Redis for many workloads
* **Persistent storage** - data survives restarts and redeployments
* **Network-isolated** - only accessible from services within the same project
* **Fully managed** - automated lifecycle management with zero configuration

***

## Troubleshooting [#troubleshooting]

### Connection refused [#connection-refused]

* Verify the `HOST` variable is correct - use the auto-generated hostname provided by Rock8Cloud
* Ensure your application service is in the same project as Dragonfly
* Check that the Dragonfly deployment completed successfully

### Client compatibility [#client-compatibility]

* Dragonfly supports the Redis protocol - use any standard Redis client
* If using advanced Redis features (e.g., Redis Modules), check [Dragonfly's compatibility docs](https://www.dragonflydb.io/docs/command-reference/compatibility)

***

## Related [#related]

* [PostgreSQL](/docs/databases-and-storage/postgresql) - Relational database
* [S3 Object Storage](/docs/databases-and-storage/s3-storage) - S3-compatible object storage
* [Environment Variables](/docs/guides/environment-variables) - Configure secrets and settings
