Slide 1

Slide 1 text

Redis

Slide 2

Slide 2 text

DATA STRUCTURES Strings, Lists, Sets, Sorted Sets, Hashes IPC Shared Memory, MQs, Semaphores, PubSub Caching Expiration, Eviction Policies

Slide 3

Slide 3 text

Time Complexity O(1) < O(log(n)) < O(n) < O(n^2) .. Containers String, Doubly Linked Lists, Skip Lists, Hash Tables ... Guaranteed, Mathematically Predictable Specialized C data structures Varies based on storage pattern

Slide 4

Slide 4 text

LIST Data Structure: Doubly Linked Lists Strengths: Time Complexity O(1) operations LPUSH LPOP RPUSH RPOP LPUSHX RPUSHX LTRIM Capped collections: Logs, Activity Feeds

Slide 5

Slide 5 text

LIST Strengths: IPC operations BLPOP BRPOP BRPOPLPUSH Blocking Atomic EM implementations Light weight APMQ replacement

Slide 6

Slide 6 text

SET Strengths: Set Operations SINTER SUNION SISMEMBER Is a friend? Common Friends. All friends of A & B. People who bought this, also bought ... Data filtering - eg. Blog Tags, N Dimension

Slide 7

Slide 7 text

SORTED SET Strengths: Scores and Ranks ZRANGEBYSCORE ZRANGE ZCOUNT ZRANK ZREMRANGEBYSCORE ZREMRANGEBYRANK Leader boards - Top something lists. Priority Queues

Slide 8

Slide 8 text

IPC Named Channels. ActiveSupport Notifications like API Pub Sub SUBSCRIBE PSUBSCRIBE PUBLISH Simple Semaphores / Distributed Locks String SETNX

Slide 9

Slide 9 text

In Short Redis is feature rich, but not a swiss knife ~Time & Memory complexity Single Threaded / Single Core Utilization Memory complexity is a funky blackbox Persistence strategy - a work in progress