Skip to content

Architecture · By Rivtor · Updated

Redis for caching vs job queues: choose the memory policy

Cache data is often replaceable; pending jobs may not be. Choose Redis memory, eviction and persistence behaviour according to the consequences of losing each key. A Redis instance provisioned for caching is not automatically an appropriate durable broker.

See the Rivtor deployment workflow →

Classify the data by loss tolerance

A cached product summary can be recomputed. A queued customer export or a payment-related job may represent work the application must not silently lose. Mixing them under one memory policy can make a successful cache design an unsafe queue design.

Inventory key types, expiration, retention and maximum payload size. Large completed-job results can use substantial memory even when the waiting queue is small. Memory planning must include broker metadata, failed jobs and cached values.

Compare the pressure behaviour

Policy classOperational consequence
Evict eligible keysWrites can continue while selected data disappears
Refuse writes at capacityProducers must handle an explicit failure
Unbounded growth assumptionProcess or host memory can become the failure boundary

The exact available policies and limits depend on the Redis deployment. Expiration and persistence are separate from eviction: writing snapshots does not prevent a key being evicted, and refusing writes does not make the storage durable by itself.

Check the managed service before choosing it

Rivtor’s Redis documentation describes its memory allowance and policy. Check that contract against the queue library’s production guidance. If the required policy or durability is unavailable, choose an appropriate external broker or another supported architecture rather than promising durable queues on unsuitable settings.

Do not change shared Redis configuration blindly to accommodate one application. A policy change can affect other consumers and requires an operational owner. This guide concerns application selection and diagnosis, not authorization to modify a production broker.

Rehearse capacity and recovery

In a disposable environment, enqueue bounded synthetic work and monitor memory as jobs complete and results accumulate. Exercise the broker’s capacity failure and confirm the producer handles it visibly. Restart the worker and broker according to a controlled test plan and compare accepted job identities with durable outputs.

Keep retries idempotent and retain only the results needed for operation. Separate cache and queue instances when their loss and pressure requirements conflict. An empty queue after a restart is not evidence of successful processing unless the expected outputs exist.

References