flippico-cache 0.5.0

Flippico cache adapter
Documentation

Cache adapter

Redis-backed adapter exposing pub/sub, FIFO list, cache, sorted-set and BullMQ capabilities.

BullMQ

Off by default. Enable the feature:

flippico-cache = { version = "0.4.1", features = ["bullmq"] }
use flippico_cache::Cache;
use flippico_cache::types::queues::{EnqueueOptions, QueueChannel};

let bull = Cache::new().bullmq().await?;

bull.enqueue(
    &QueueChannel::KsefGpt,
    "run-workflow",
    serde_json::json!({ "workflow_id": 42 }),
    Some(EnqueueOptions {
        attempts: Some(3),
        ..Default::default()
    }),
)
.await?;

Jobs are written by BullMQ's own Lua scripts, in BullMQ's own key layout, so a Node, Python, PHP or Elixir BullMQ worker consumes them unchanged and Bull Board sees the queues as normal. The enqueue above produces exactly:

bull:ksef-gpt:id        bull:ksef-gpt:wait      bull:ksef-gpt:meta
bull:ksef-gpt:events    bull:ksef-gpt:marker    bull:ksef-gpt:1     (the job hash)

Capabilities

Producing: enqueue, enqueue_bulk. Job options: delay, priority, attempts with fixed or exponential backoff, remove_on_complete / remove_on_fail, custom job ids, deduplication.

Inspecting: job_counts, get_job, list_jobs (waiting / active / delayed / prioritized / completed / failed), pause, resume, is_paused, obliterate.

Consuming jobs (a Worker), queue events, flows and scheduled jobs are not yet implemented — see docs/superpowers/specs/2026-08-25-bullmq-support-design.md.

Queue names

QueueChannel mirrors the existing ListChannel / CacheSpace pattern, with Custom(String) for queues not worth a crate release. Names are lowercase-kebab (ksef-gpt, bajkomat-api) because they appear in dashboards and must match any non-Rust consumer exactly.

Custom is an escape hatch, not a dynamic namespace: the provider caches one connection pool per distinct queue name and never evicts, so minting a fresh name per request or per tenant would accumulate pools without bound.

Configuration

Variable Purpose Default
FLIPPICO_CACHE_REDIS_URL Redis connection, shared with all other capabilities required
FLIPPICO_CACHE_BULLMQ_PREFIX BullMQ key prefix bull

Keep the prefix at bull unless you need isolation — it is what BullMQ tooling expects.

Notes

  • Cache::bullmq() is async, unlike the other four builders. BullMQ's job lifecycle cannot be driven from a blocking call, and block_on inside an existing Tokio runtime panics.
  • Every BullMQ method returns a Result. The older sync traits log and return (); for a queue that would be silent data loss.
  • Enabling this feature links a second major version of the redis crate (1.6.0, required by bullmq-official) alongside this crate's 0.32.5. Both compile and coexist correctly; it costs build time and binary size.
  • bullmq-official is pinned to an exact version (=1.2.6). Upgrade deliberately, not via a caret range.

Testing

Integration tests need a Redis and skip cleanly, with a printed notice, when none is listening:

docker run -d --rm -p 6379:6379 --name flippico-test-redis redis:7
cargo test --features bullmq --test bullmq_producer

Override the target with FLIPPICO_CACHE_TEST_REDIS_URL. These tests never read FLIPPICO_CACHE_REDIS_URL, so they cannot touch a production server.

⚠️ The pre-existing tests inside src/lib.rs (fifo_test, publish_test, cache_test_set, cache_test_del) do read FLIPPICO_CACHE_REDIS_URL and will read and write against whatever server .env points at. Scope test runs to --test bullmq_producer unless you intend that.