Dragonfly
Neutron uses Dragonfly as its primary engine for caching, sessions, and background jobs.
What is Dragonfly?
Dragonfly is a modern, multithreaded, drop-in replacement for Redis. It supports the same wire protocol but offers significantly higher performance.
- 25x Throughput: On multi-core systems, Dragonfly utilizes all available cores.
- Memory Efficient: Uses up to 30% less memory than Redis in many scenarios.
- No Snapshots Spikes: Avoids the memory spikes common during Redis snapshots.
Usage in Neutron
You don't need to learn a new API. Neutron uses standard Redis-compatible clients under the hood.
Caching
// Using the unified cache module
await context.cache.set("key", "value", { ttl: 60 });
Sessions
Sessions are automatically stored in Dragonfly by the nucleus session module, ensuring your app servers remain stateless and easy to scale.
Queues (BullMQ)
Neutron integrates with BullMQ for background job processing, using Dragonfly as the backend.
// Define a job
export const myJob = defineJob("process-video", async (data) => {
// heavy processing...
});
// Trigger a job from an action
await myJob.enqueue({ id: 123 });