Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
15 posts found
What Is Redis Beyond a Cache? The In-Memory Data Structure Server, Use Cases and Licensing
Database PART 01

What Is Redis Beyond a Cache? The In-Memory Data Structure Server, Use Cases and Licensing

Redis is an in-memory server that keeps data structures, from strings to streams, under keys and runs commands one at a time on a single main thread; that is why every command is atomic and why one long command makes everyone wait. With real measurements: a 105 ms KEYS stalling another client's PING, 100,000 INCRs without a lock, server time versus round trip, a map of uses beyond caching, where Redis is a poor fit, the licensing history and how Valkey differs.

14 Nov 2026 13 min 9
Redis Lab and StackExchange.Redis: Docker, redis-cli, Redis Insight, ConnectionMultiplexer and Key Design
Database PART 02

Redis Lab and StackExchange.Redis: Docker, redis-cli, Redis Insight, ConnectionMultiplexer and Key Design

In StackExchange.Redis there should be one ConnectionMultiplexer per application: each multiplexer opens two connections, so creating one per request turns 200 requests into 400 connections and replies ten times slower. With real output: a compose lab with Redis 8 and Valkey 9, redis-cli latency modes, an unread MONITOR eating 101 MB, Redis Insight, RESP3 and the separate pub/sub connection, a 300x gain from pipelining, a 110-second timeout from sync over async, and listing keys with SCAN.

14 Nov 2026 13 min 9
Redis Strings and Expiration: SET Options, Counters, Compare-and-Set and TTL Semantics
Database PART 03

Redis Strings and Expiration: SET Options, Counters, Compare-and-Set and TTL Semantics

Overwriting a Redis key with SET removes its TTL; rewrite a verification code without EX and it is never deleted. With real output: SET options and KEEPTTL, a daily counter with INCR and EXPIRE NX, GET + SET losing 9,617 of 10,000 increments, a one-time code and an idempotency key built on Redis 8.4's SET IFEQ, DELEX and DIGEST, the Valkey differences, and how expiration works inside through lazy and active deletion.

14 Nov 2026 14 min 7
Redis Hashes: Storing Objects, Field Expiration and Memory Efficiency
Database PART 04

Redis Hashes: Storing Objects, Field Expiration and Memory Efficiency

A small Redis hash lives in the listpack encoding and holds the same cart in half the memory of a JSON string and well under half of separate keys; the 513th field or a single 65-byte value turns it into a hashtable and multiplies memory by 3.4. With real output: Bookstore's cart with HashEntry, choosing between a hash and JSON, a per-field price lock with HEXPIRE and HSETEX, Valkey's encoding difference, Redis 8.10's compact hashes via HIMPORT, and a 44 ms HGETALL on a huge hash.

14 Nov 2026 10 min 7
Redis Lists and Sets: Simple Queues, Reliable Queues, Recently Viewed Items and Tags
Database PART 05

Redis Lists and Sets: Simple Queues, Reliable Queues, Recently Viewed Items and Tags

If a worker that took a job with RPOP crashes, the job is lost; LMOVE moves the job to a processing list in the same atomic step, so it can be recovered after a crash. With real output: the reliable queue and its limits, Redis 8.10's LMOVEM, BLPOP freezing an application for 3 seconds on a shared multiplexer, the last 10 viewed books with LTRIM, book tags in an intset and SINTER, weekly unique visitors with SUNIONCARD, and a 67 ms SMEMBERS on a big set.

14 Nov 2026 11 min 8
Redis Sorted Sets: Leaderboards, Time-Windowed Rankings and Pagination
Database PART 06

Redis Sorted Sets: Leaderboards, Time-Windowed Rankings and Pagination

A Redis sorted set keeps every member with a score and stays ordered at all times; rank and page queries on a leaderboard take microseconds even with a million members, but paging a live list by rank drifts between two requests. With real output: ZADD options, paging with ZRANGE, the week's bestsellers from daily sets with ZUNIONSTORE and Redis 8.8's COUNT, the order of equal scores, the 2^53 precision limit, and sliding windows that use a timestamp as the score.

14 Nov 2026 17 min 9
Special Data Types: Bitmaps, HyperLogLog, Geospatial and Probabilistic Structures (Bloom, Cuckoo, Top-K)
Database PART 07

Special Data Types: Bitmaps, HyperLogLog, Geospatial and Probabilistic Structures (Bloom, Cuckoo, Top-K)

For unique counting, a bitmap gives the exact result with about a fiftieth of a set's memory when identities are dense; HyperLogLog counts any kind of identity in 12 KB with roughly 1 % error. With real output: set, bitmap and HLL on the same visitor data, the 14 MB trap of a sparse bitmap, BITFIELD, Geo for the nearest warehouse, a Bloom filter's measured memory and false positive rate, Cuckoo, Top-K, Count-Min Sketch, t-digest, Redis 8.8's Array and the Valkey differences.

14 Nov 2026 15 min 10
Atomicity in Redis: MULTI/EXEC, WATCH, Lua Scripts and Redis Functions
Database PART 08

Atomicity in Redis: MULTI/EXEC, WATCH, Lua Scripts and Redis Functions

In Redis, MULTI/EXEC runs commands in order with nobody in between, but it does not roll back; for multi-step work that decides based on a read, the right tool is usually a Lua script. With real output: a stock of 100 copies sold 200 times, 14,620 retries with WATCH, StackExchange.Redis conditions, stock reservation with LuaScript.Prepare, the script cache, Redis Functions surviving a restart, Redis 8.8's INCREX and a long script that locks the server.

14 Nov 2026 15 min 10
Redis Pub/Sub and Keyspace Notifications: Sharded Pub/Sub, At-Most-Once and Cache Invalidation Signals
Database PART 09

Redis Pub/Sub and Keyspace Notifications: Sharded Pub/Sub, At-Most-Once and Cache Invalidation Signals

Redis pub/sub delivers a message only to the listeners connected at that moment and stores it nowhere; a message published while a connection is down never arrives. With real output: at-most-once delivery, message order with a handler versus a ChannelMessageQueue, a 40 MB GET dropping a shared connection, L1 invalidation across two API instances, a work-available signal for a queue, sharded pub/sub, late expired events, hash field notifications and a slow subscriber.

14 Nov 2026 12 min 11
Redis Streams: Consumer Groups, the Pending Entry List, XAUTOCLAIM and Idempotent XADD
Database PART 10

Redis Streams: Consumer Groups, the Pending Entry List, XAUTOCLAIM and Idempotent XADD

In Redis Streams a consumer group keeps every event it handed out but that was not acknowledged in the pending entry list; a crashed worker's work is not lost and moves to another worker in a single read with Redis 8.4's XREADGROUP CLAIM. With real output: stream structure, two independent consumer groups, immediate retry with XNACK, Redis 8.6's idempotent XADD with IDMP, a BackgroundService worker, a dead-letter stream for poison messages and XTRIM's default 10,000-entry limit.

14 Nov 2026 14 min 16
Redis JSON and the Query Engine: JSON Documents, FT.CREATE, FT.SEARCH, FT.AGGREGATE and NRedisStack
Database PART 11

Redis JSON and the Query Engine: JSON Documents, FT.CREATE, FT.SEARCH, FT.AGGREGATE and NRedisStack

In Redis 8 you can partially update JSON documents with JSONPath and filter and sort them with FT.SEARCH over an index built with FT.CREATE; search sees the new value as soon as the write command returns. With real output: catalog search with NRedisStack, tag escaping, GROUPBY counting only the first value of multi-value fields, the limits of Turkish stemming and the dotted capital I, index cost for 100,000 books and how valkey-search differs.

14 Nov 2026 13 min 10
Redis Persistence and Memory Management: RDB, AOF, fsync, Fork Cost, maxmemory and Big/Hot Keys
Database PART 12

Redis Persistence and Memory Management: RDB, AOF, fsync, Fork Cost, maxmemory and Big/Hot Keys

The official redis:8 image takes only periodic RDB snapshots by default; if the container dies with SIGKILL everything after the last snapshot is gone, while with AOF everysec no order was lost in the measurement. With real output: fork and copy-on-write cost, turning on AOF without losing data, Redis 8.10's BACKUP command, noeviction protecting a stream, OOMKilled, UNLINK, HOTKEYS and the activedefrag threshold.

14 Nov 2026 11 min 10
Blog Map