redis

  • SCAN with a MATCH pattern is still O(n) overall

    SCAN is the safe replacement for KEYS because each call does bounded work, and the pattern is applied after the keys are fetched — so scanning a million…

  • Redis streams, and the broker you might not need

    5.0 shipped in October with a log-structured type and consumer groups. A list has no acknowledgement, which is why a crashed consumer loses the message.

  • Seven services in one development environment

    Apache, Nginx, PHP, MySQL, Redis, Beanstalkd and a mail catcher, on a laptop. Onboarding measured in minutes rather than days, and what it costs to run.

  • Consumer groups, and the pending entries list

    Reading a stream directly gives every consumer every message. A consumer group distributes entries between members and remembers which ones were handed out and not acknowledged. The pending…

  • Cache the computation, not the query result

    Caching the rows a query returned saves the database round trip and leaves the hydration, the mapping and the aggregation to happen on every request anyway. Profiling usually…

  • A cache stampede, and the lock that prevents it

    An expensive cached value expires under load and every concurrent request misses simultaneously, so forty requests all run the same four-second query at once and the database falls…

  • A queue table is not a queue

    SELECT … WHERE processed = 0 LIMIT 1, and two workers taking the same row. SKIP LOCKED makes the table viable; it does not make it a broker.

  • A stream is not a list, and XADD is not RPUSH

    A list used as a queue loses the message when a consumer crashes mid-work, because BRPOP removes it and there is no record that anything was in flight.…

  • XAUTOCLAIM does not exist yet, so XCLAIM and a timer

    When a consumer dies its pending entries belong to a name that will never acknowledge them, so something has to reassign them — and in Redis 5 that…

  • A Redis container without persistence is a deliberate choice

    The official Redis image saves to disk by default, and a cache that survives a restart is occasionally what you want and usually a way to carry a…