{"slug":"cache-overview","title":"Cache Instances Overview","description":"DanubeData provides fully managed in-memory cache instances — Redis, Valkey, and Dragonfly — with persistence, replication, and high availability.","section":"Features","url":"https://docs.danubedata.ro/cache-overview","markdown_url":"https://docs.danubedata.ro/cache-overview.md","breadcrumbs":[{"title":"Features","slug":null},{"title":"Cache","slug":"cache-overview"}],"headings":[{"level":1,"title":"Cache Instances Overview","id":"cache-instances-overview"},{"level":2,"title":"What are Cache Instances?","id":"what-are-cache-instances"},{"level":2,"title":"Cache Engines","id":"cache-engines"},{"level":2,"title":"Core Features","id":"core-features"},{"level":3,"title":"Key Features","id":"key-features"},{"level":3,"title":"Use Cases","id":"use-cases"},{"level":2,"title":"Getting Started","id":"getting-started"},{"level":3,"title":"Create a Cache Instance","id":"create-a-cache-instance"},{"level":3,"title":"Connect to Your Cache","id":"connect-to-your-cache"},{"level":3,"title":"External Access","id":"external-access"},{"level":2,"title":"Resource Profiles","id":"resource-profiles"},{"level":3,"title":"Redis / Valkey","id":"redis-valkey"},{"level":3,"title":"Dragonfly (40–50% premium for multi-threaded performance)","id":"dragonfly-4050-premium-for-multi-threaded-performance"},{"level":2,"title":"Persistence Options","id":"persistence-options"},{"level":3,"title":"No Persistence","id":"no-persistence"},{"level":3,"title":"RDB (Redis Database Backup)","id":"rdb-redis-database-backup"},{"level":3,"title":"AOF (Append-Only File)","id":"aof-append-only-file"},{"level":3,"title":"RDB + AOF","id":"rdb-aof"},{"level":2,"title":"Replication","id":"replication"},{"level":3,"title":"Add a Replica","id":"add-a-replica"},{"level":3,"title":"Benefits","id":"benefits"},{"level":2,"title":"Monitoring","id":"monitoring"},{"level":3,"title":"Key Metrics","id":"key-metrics"},{"level":3,"title":"Memory Management","id":"memory-management"},{"level":2,"title":"Snapshots","id":"snapshots"},{"level":3,"title":"Automated Snapshots","id":"automated-snapshots"},{"level":3,"title":"Use Cases","id":"use-cases"},{"level":2,"title":"Upgrading the Engine Version","id":"upgrading-the-engine-version"},{"level":2,"title":"Migrating a Legacy Cache to the Managed Operator","id":"migrating-a-legacy-cache-to-the-managed-operator"},{"level":2,"title":"Best Practices","id":"best-practices"},{"level":3,"title":"Performance","id":"performance"},{"level":3,"title":"Security","id":"security"},{"level":3,"title":"Reliability","id":"reliability"},{"level":3,"title":"Memory Management","id":"memory-management"},{"level":2,"title":"Common Operations","id":"common-operations"},{"level":3,"title":"Session Storage","id":"session-storage"},{"level":3,"title":"Caching","id":"caching"},{"level":3,"title":"Leaderboard","id":"leaderboard"},{"level":3,"title":"Pub/Sub","id":"pubsub"},{"level":2,"title":"Troubleshooting","id":"troubleshooting"},{"level":3,"title":"High Memory Usage","id":"high-memory-usage"},{"level":3,"title":"Slow Performance","id":"slow-performance"},{"level":3,"title":"Connection Issues","id":"connection-issues"},{"level":2,"title":"Next Steps","id":"next-steps"}],"format":"markdown","word_count":1362,"content":"# Cache Instances Overview\n\nDanubeData provides fully managed in-memory cache instances — Redis, Valkey, and Dragonfly — with persistence, replication, and high availability.\n\n## What are Cache Instances?\n\nCache instances are managed in-memory data stores that provide:\n\n- **High Performance**: In-memory data storage\n- **Persistence**: Optional data persistence to disk\n- **Replication**: Read replicas for scaling\n- **Monitoring**: Real-time performance metrics\n- **Security**: Firewall integration and authentication\n\n## Cache Engines\n\nChoose the engine that best fits your workload — all three speak the Redis protocol, so existing Redis clients and libraries work unchanged:\n\n- **Redis** — the industry-standard in-memory store. Versions 7.2, 7.4, 8.0, and 8.4 (8.4 is the default for new instances). Redis 8.0 and later bundle vector sets, native JSON, time series, and bloom-filter data types in the core engine, with I/O threading enabled for higher throughput.\n- **Valkey** — an open-source, Redis-compatible fork with no licensing restrictions. Versions 7.2 through 9.1 (9.1 is the default).\n- **Dragonfly** — a multi-threaded, Redis-compatible engine that scales with your CPU count for much higher single-instance throughput. Versions 1.23 and 1.24. Priced at a 40–50% premium over Redis/Valkey for the added performance.\n\n## Core Features\n\n### Key Features\n- **In-Memory Storage**: Lightning-fast read/write operations\n- **Data Structures**: Strings, hashes, lists, sets, sorted sets\n- **Pub/Sub**: Message broker functionality\n- **Lua Scripting**: Server-side script execution\n- **Transactions**: MULTI/EXEC support\n- **Persistence**: RDB and AOF options\n\n### Use Cases\n- **Session Storage**: Store user sessions\n- **Caching**: Cache database queries and API responses\n- **Real-time Analytics**: Count and track events\n- **Message Queue**: Task queue and pub/sub messaging\n- **Leaderboards**: Sorted sets for rankings\n\n## Getting Started\n\n### Create a Cache Instance\n\n1. Navigate to **Cache Instances** in the main menu\n2. Click **Create Cache Instance**\n3. Enter a name for your instance\n4. Choose an engine (Redis, Valkey, or Dragonfly) and version\n5. Select a resource profile\n6. Configure persistence settings\n7. Click **Create Cache**\n\nYour cache instance will be ready in 1-2 minutes!\n\n### Connect to Your Cache\n\nOnce your cache is running, you'll receive:\n- **Hostname**: Connection endpoint\n- **Port**: 6379 on the private network. With public DNS enabled, the public\n  hostname listens on its own port instead — see [External Access](#external-access)\n- **Password**: Secure password\n\n**Example Connection:**\n```bash\nredis-cli -h your-cache-hostname -p 6379 -a your-password\n```\n\n**Example with Code:**\n```python\nimport redis\n\nr = redis.Redis(\n    host='your-cache-hostname',\n    port=6379,\n    password='your-password'\n)\n\nr.set('key', 'value')\nprint(r.get('key'))\n```\n\n### External Access\n\nBy default your cache is reachable over your team's private network. To connect from outside the platform, enable **public DNS** on the instance — this opens external access and updates the firewall automatically so clients can connect right away. Turning it back off closes that path just as cleanly.\n\n**The public endpoint uses a different port than the private one.** Public\ntraffic arrives through a shared load balancer, where your instance gets its own\ndedicated port — not 6379. Port 6379 stays correct for private-network\nconnections. Always copy the port shown next to the endpoint in the dashboard, or\nread it from the API:\n\n| Where you connect from | Hostname | Port |\n|---|---|---|\n| Private network (VPS, other DanubeData resources) | short in-cluster name | `port` (6379) |\n| Public internet (public DNS enabled) | public DNS hostname | `dns_port` |\n\nDNS records cannot carry a port number, so resolving the hostname tells you\nnothing about which port to use. API clients should read `connection_host` and\n`connection_port` — they always resolve to the correct pair:\n\n```bash\ncurl -H \"Authorization: Bearer $DANUBEDATA_TOKEN\" \\\n  https://api.danubedata.ro/api/v1/cache/$CACHE_ID/connection-info\n```\n\n```json\n{\n  \"host\": \"redis-sessions.acme.danubedata.ro\",\n  \"port\": 6385,\n  \"username\": \"default\",\n  \"password\": \"...\",\n  \"connection_info\": \"redis://default:...@redis-sessions.acme.danubedata.ro:6385\"\n}\n```\n\n`GET /api/v1/cache/{id}/credentials` is a compatibility alias that returns the\nidentical payload; `connection-info` is the canonical route.\n\nTraffic between your cache and your other DanubeData resources over the private network is free — it does not count as billed egress.\n\n## Resource Profiles\n\nCache profiles are sized by memory. Billing is hourly with a monthly cap; check the dashboard for the live rate.\n\n### Redis / Valkey\n\n| Profile | Memory | Monthly |\n|---------|--------|---------|\n| Micro | 256 MB | €4.99 |\n| Small | 1 GB | €9.99 |\n| Medium | 3 GB | €19.99 |\n| Large | 6 GB | €39.99 |\n\n### Dragonfly (40–50% premium for multi-threaded performance)\n\n| Profile | Memory | Monthly |\n|---------|--------|---------|\n| Micro | 256 MB | €6.99 |\n| Small | 1 GB | €14.99 |\n| Medium | 3 GB | €29.99 |\n| Large | 6 GB | €59.99 |\n\n## Persistence Options\n\n### No Persistence\n- Fastest performance\n- Data lost on restart\n- Best for: Temporary caching\n\n### RDB (Redis Database Backup)\n- Point-in-time snapshots\n- Low performance impact\n- Best for: General caching with occasional persistence\n\n### AOF (Append-Only File)\n- Every write operation logged\n- Maximum durability\n- Best for: Session storage, critical data\n\n### RDB + AOF\n- Best of both worlds\n- Highest durability\n- Best for: Production workloads requiring persistence\n\n## Replication\n\nScale read operations with replicas:\n\n### Add a Replica\n\n1. Go to your cache instance page\n2. Click **Add Replica**\n3. Select a node\n4. Click **Create Replica**\n\n### Benefits\n- **Read Scaling**: Offload reads to replicas\n- **High Availability**: Automatic failover\n\n## Monitoring\n\nTrack cache performance:\n\n### Key Metrics\n- **CPU Usage**: Monitor compute resources\n- **Memory Usage**: Track memory utilization\n- **Connections**: Active client connections\n- **Operations per Second**: Command throughput\n- **Hit Rate**: Cache hit/miss ratio\n- **Network I/O**: Bandwidth usage\n\n### Memory Management\n- Monitor memory usage to prevent OOM\n- Set eviction policies (LRU, LFU, etc.)\n- Configure max memory limit\n\n## Snapshots\n\nCreate point-in-time snapshots:\n\n1. Go to your cache instance page\n2. Click **Snapshots** tab\n3. Click **Create Snapshot**\n4. Enter a name\n5. Click **Create**\n\n### Automated Snapshots\n\nRunning cache instances are also snapshotted automatically on a daily schedule, with configurable retention. Automated snapshots run only while an instance is running, so a stopped cache never accrues wasted backups.\n\n### Use Cases\n- Backup before major changes\n- Clone cache instances\n\n## Upgrading the Engine Version\n\nMove an instance to a newer Redis, Valkey, or Dragonfly version without recreating it:\n\n1. Open the **Updates** tab on your cache instance\n2. Review the versions you can upgrade to and start with one click\n3. A snapshot is taken automatically first, so you can restore if anything looks wrong afterward\n4. Track progress live on the instance page — the instance shows an **Updating** status while the upgrade runs\n\n## Migrating a Legacy Cache to the Managed Operator\n\nNew Redis and Dragonfly caches run on our managed-operator backend by default. If you have an older standalone instance, you can move it across yourself:\n\n1. Open the actions menu on an eligible cache instance and choose **Migrate to managed operator**\n2. Available for standalone (non-replicated), running Redis and Dragonfly instances — Valkey support is on the way\n3. Track migration progress live, from snapshot through cutover\n4. A short downtime window applies during cutover; your password and existing data carry over unchanged\n5. Afterwards you get a grace period to confirm everything looks right or roll back — it auto-confirms if you take no action\n\n## Best Practices\n\n### Performance\n1. Use connection pooling\n2. Batch commands with pipelining\n3. Use appropriate data structures\n4. Monitor memory usage\n5. Set appropriate TTLs\n\n### Security\n1. Use strong passwords\n2. Enable firewalls\n3. Use private networks\n4. Disable dangerous commands\n5. Regular security updates\n\n### Reliability\n1. Enable persistence for important data\n2. Use replicas for high availability\n3. Take regular snapshots\n4. Monitor replication lag\n5. Test failover procedures\n\n### Memory Management\n1. Set max memory limits\n2. Configure eviction policies\n3. Monitor memory usage\n4. Remove expired keys regularly\n5. Use appropriate TTLs\n\n## Common Operations\n\n### Session Storage\n```python\n# Store session\nr.setex(f'session:{user_id}', 3600, session_data)\n\n# Get session\nsession = r.get(f'session:{user_id}')\n```\n\n### Caching\n```python\n# Check cache first\ncached = r.get('api:users:list')\nif cached:\n    return cached\n\n# Fetch from database\ndata = fetch_from_database()\n\n# Cache for 5 minutes\nr.setex('api:users:list', 300, data)\nreturn data\n```\n\n### Leaderboard\n```python\n# Add score\nr.zadd('leaderboard', {user_id: score})\n\n# Get top 10\ntop_users = r.zrevrange('leaderboard', 0, 9, withscores=True)\n```\n\n### Pub/Sub\n```python\n# Publisher\nr.publish('notifications', 'New message')\n\n# Subscriber\npubsub = r.pubsub()\npubsub.subscribe('notifications')\nfor message in pubsub.listen():\n    print(message)\n```\n\n## Troubleshooting\n\n### High Memory Usage\n1. Check memory stats with `INFO memory`\n2. Review eviction policy\n3. Set appropriate TTLs\n4. Consider upgrading to larger profile\n\n### Slow Performance\n1. Check CPU usage\n2. Review slow log\n3. Use pipelining for multiple commands\n4. Add read replicas for read-heavy workloads\n\n### Connection Issues\n1. Verify firewall rules\n2. Check connection limits\n3. Use connection pooling\n4. Review network latency\n\n## Next Steps\n\n- [Redis Best Practices](https://docs.danubedata.ro/cache-redis)\n- [Redis Replicas](https://docs.danubedata.ro/cache-replicas)\n- [Data Persistence](https://docs.danubedata.ro/cache-persistence)\n- [Monitoring Guide](https://docs.danubedata.ro/cache-monitoring)\n\nNeed help? Contact our support team through the dashboard.\n\n","prev":{"title":"Parameter Groups","slug":"databases-parameters","url":"https://docs.danubedata.ro/databases-parameters","markdown_url":"https://docs.danubedata.ro/databases-parameters.md","json_url":"https://docs.danubedata.ro/databases-parameters.json"},"next":{"title":"Redis","slug":"cache-redis","url":"https://docs.danubedata.ro/cache-redis","markdown_url":"https://docs.danubedata.ro/cache-redis.md","json_url":"https://docs.danubedata.ro/cache-redis.json"},"index_url":"https://docs.danubedata.ro/index.json"}