@vasto-queue/redis-store
v0.1.0
Published
Redis storage adapter for Vasto
Maintainers
Readme
@vasto-queue/redis-store
Redis storage adapter for Vasto.
Uses ioredis with a Lua-scripted atomic dequeue that handles visibility timeouts and expired-lease reclaim without external locks.
Installation
npm install @vasto-queue/redis-store ioredisUsage
import { RedisStore } from '@vasto-queue/redis-store';
const store = new RedisStore({
client: {
host: 'localhost',
port: 6379,
},
});Or pass a pre-configured ioredis instance:
import Redis from 'ioredis';
import { RedisStore } from '@vasto-queue/redis-store';
const redis = new Redis({ host: 'localhost', port: 6379 });
const store = new RedisStore({ client: redis });Pass the store as a connection adapter to your queue config:
import { defineQueues, defineWorkers } from '@vasto-queue/core';
const queues = defineQueues({
default: {
name: 'default',
connection: 'redis',
concurrency: 5,
batchSize: 10,
retry: { attempts: 3, maxAttempts: 3, backoff: 'exponential' },
},
});
const storageAdapters = { redis: store };Key Layout
| Key | Type | Purpose |
|---|---|---|
| vasto:job:{id} | string (JSON) | Full job payload |
| vasto:queue:{name}:ready | sorted set (score = createdAt) | Jobs waiting to run |
| vasto:queue:{name}:leased | sorted set (score = leaseUntil) | Inflight jobs |
| vasto:dead:{id} | string (JSON) | Dead-lettered job copy |
| vasto:queue:{name}:dead | sorted set (score = failedAt) | Dead-letter index |
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
| client | Redis \| RedisOptions | — | ioredis instance or config |
| prefix | string | vasto | Key namespace prefix |
