# Redis and Caching

> Improve application performance with Redis or Valkey caching services.

Caching Services
----------------

Ploi Cloud supports both Redis and Valkey for in-memory caching and session storage.

### Redis vs Valkey

- **Redis:** In-memory data structure store
- **Valkey:** High-performance key-value store with full Redis compatibility

### Adding a Cache Service

1. Navigate to your application's overview
2. Find the "Cache" card
3. Click "Create" to add your first cache service (or "Add cache" if you already have services)
4. Select Redis or Valkey as the cache type
5. Configure resources using the CPU slider
6. Set storage size for data persistence (cannot be changed after creation)
7. Optionally select a specific version or leave blank for latest

### Laravel Configuration

For Laravel applications, the following environment variables are automatically injected:

#### Redis
- `REDIS_URL` - Full connection URL with authentication
- `REDIS_HOST` - Redis hostname
- `REDIS_PORT` - Redis port
- `REDIS_PASSWORD` - Redis password

#### Valkey
- `VALKEY_URL` - Full connection URL with authentication
- `VALKEY_HOST` - Valkey hostname
- `VALKEY_PORT` - Valkey port
- `VALKEY_PASSWORD` - Valkey password

Update your Laravel cache configuration to use these variables:

```
  CACHE_DRIVER=redis
  SESSION_DRIVER=redis
```

### Resource Configuration

When creating a cache service, you can configure:

- **CPU:** Adjustable via slider (from 0.25 to multiple cores)
- **Memory:** Configurable based on your needs
- **Storage:** Persistent volume for data (e.g., "8Gi", "10Gi")

### Service Management

Manage your cache service through the application dashboard:

- View service logs for troubleshooting
- Restart the service when needed
- Enable temporary debug access for direct connections
- Monitor service status (active, stopped, failed)
- Edit resources to scale up or down
