Redis and Dragonfly

View as Markdown

Neutron does not require Dragonfly. Its optional Redis integrations accept a Redis or Dragonfly connection URL because both expose the commands these drivers use.

Cache client

import { createRedisCacheClient } from "@neutron-build/data";

const cache = await createRedisCacheClient({
  url: process.env.DRAGONFLY_URL ?? process.env.REDIS_URL,
  keyPrefix: "my-app:",
});

await cache.set("status", "ready", 60);
const status = await cache.get("status");
await cache.close();

The client implements get, set, del, and incr. If no URL is passed, it checks DRAGONFLY_URL, then REDIS_URL, then uses redis://127.0.0.1:6379.

BullMQ queue

BullMQ and ioredis are optional peer dependencies:

npm install @neutron-build/data bullmq ioredis
import { createBullMqQueueDriver } from "@neutron-build/data";

const queue = await createBullMqQueueDriver({ queueName: "media" });

await queue.process("transcode", async (job) => {
  await transcode(job.payload);
});

await queue.add("transcode", { assetId: "asset_123" });

@neutron-build/data also exports Redis-compatible session and realtime drivers. These are explicit application choices; Neutron does not start or configure a Dragonfly server automatically.