A Brief Introduction to Redis
Upcoming SlideShare
Loading in...5
×
 

A Brief Introduction to Redis

on

  • 1,090 views

This is a brief, high-level overview of Redis, a networked data structure server.

This is a brief, high-level overview of Redis, a networked data structure server.

Statistics

Views

Total Views
1,090
Views on SlideShare
1,089
Embed Views
1

Actions

Likes
0
Downloads
11
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

A Brief Introduction to Redis A Brief Introduction to Redis Presentation Transcript

  • A Brief Introduction to Redis Charles Anderson ! Salem Dynamic Languages User Group January 2014
  • Overview • Redis is a networked “data structure server” • Fast, powerful, simple
  • Abstract Data Types • In the Before Time, we didn’t have classes and objects - we had abstract data types • and, we liked it! • Procedural interface • First (or last) parameter is the ADT
  • Example: Stack • push(stack, item) • pop(stack): item • size(stack): int • etc.
  • Stack ADT • We had a single, global name space. So: • stack_push(stack, item) • stack_pop(stack) • stack_size(stack) • This is what the Redis API looks like
  • Redis Types • String - scalar value • List • Set • Sorted Set • Hash
  • Redis List • A small subset of the operations: • LPUSH key value • LPOP key • LLEN key • LRANGE key start stop
  • Redis API • Every object has a name/key • First parameter to each call • Every object has a type • Operation must match the type of object
  • Using API via CLI $ redis-cli redis 127.0.0.1:6379> lpush mylist 1 (integer) 1 redis 127.0.0.1:6379> lpush mylist cat (integer) 2 redis 127.0.0.1:6379> lpush mylist 3.14 (integer) 3 redis 127.0.0.1:6379> llen mylist (integer) 3 redis 127.0.0.1:6379> lrange mylist 0 1 1) "3.14" 2) "cat" redis 127.0.0.1:6379> lrange mylist 0 -1 1) "3.14" 2) "cat" 3) "1"
  • Redis Clients • The wire protocol for Redis is dead-simple • Therefore, lots of clients for lots of languages
  • Ruby Client Demo irb(main):015:0> r.lpush('mylist', 1) => 1 irb(main):016:0> r.lpush('mylist', 'cat') => 2 irb(main):017:0> r.lpush('mylist', 3.14) => 3 irb(main):019:0> r.lrange('mylist', 0, -1) => ["3.14", "cat", "1"]
  • Complete Redis API • http://redis.io/commands • Each command includes the time complexity of the operation - unique
  • Set • SADD key member, SREM key member • SCARD key • SISMEMEBER key member • SINTER, SUNION
  • Sorted Set • ZADD key score member • ZSCORE key member • ZRANK key member • ZRANGE key start stop • Use case: leader board
  • Hash • HSET key field value • HGET key field • HEXISTS key field, HKEYS, HLEN • Use case: a structured record like User
  • Other Stuff • Key Expiration • Transactions/batches • Publish-Subscribe • Server-side scripting via Lua • Replication • Clustering
  • Implementation Details • Everything is stored in memory • • Hella fast Not memcache - expiration is not LRU • Persistent - tunable disk storage • Single-threaded - simple, fast, single CPU • Support (@antirez) is awesome
  • But, is it Web Scale? • NoSQL key/value store • Kickass benchmarks • Simpler (smaller scope) than HBase or Cassandra • Sharding done by clients • Not usually a system of record • I already work on a farm
  • More Information • http://redis.io • “The Little Redis Book” Seguin • “Redis in Action” Carlson • “Redis Cookbook” Macedo and Oliveira
  • Questions •?