Slide 1

Slide 1 text

I am Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Mark Paluch, Software Engineer, Pivotal Software Inc., lettuce Driver Project Lead @mp911de

Slide 2

Slide 2 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Mark Paluch @mp911de github.com/mp911de paluch.biz

Slide 3

Slide 3 text

Remote Dictionary Server

Slide 4

Slide 4 text

Sicily (Italien) https://www.flickr.com/photos/alebaffa/8736896248/

Slide 5

Slide 5 text

Salvatore Sanfilippo @antirez https://github.com/antirez/redis http://antirez.com/

Slide 6

Slide 6 text

Overview § 100% Open Source § Drivers provided by community § In-Memory Operations § Append Only File and Snapshots

Slide 7

Slide 7 text

Redis Setup $ wget http://download.redis.io/releases/ redis-3.2.5.tar.gz | tar xzf - $ cd redis-3.2.5 $ make $ src/redis-server $ brew install redis $ docker run --name redis -d redis:alpine $ apt-get install redis-server

Slide 8

Slide 8 text

Unless otherwise indicated, these slides are 
 © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Redis Console Demo

Slide 9

Slide 9 text

Running Redis § Redis Standalone (Single-Node, Master-Slave) § Redis Sentinel (Master/Slave Failover) § Redis Cluster (Sharding, Slaves)

Slide 10

Slide 10 text

Redis Security § Use a Firewall § Password-Authentication § SSL (using stunnel)

Slide 11

Slide 11 text

https://www.flickr.com/photos/beckyjohns/4629502158 Use-Cases

Slide 12

Slide 12 text

Redis Use-Cases § Key-Value store § Caching § Queues § High-speed data ingestion § Distributed Sessions § Distributed Locks § Real-Time Analytics § Geo-Indexing

Slide 13

Slide 13 text

Redis: Datastructure Server § Key-Value § Hashes § Lists § Sorted Sets § Geospatial Index
 § Publish/Subscribe § HyperLogLog § Transactions § Scripting

Slide 14

Slide 14 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ SELECT firstname FROM people WHERE id = 7 key: 7 value: Mark key: people:7 field value firstname Mark

Slide 15

Slide 15 text

Clients

Slide 16

Slide 16 text

Unless otherwise indicated, these slides are 
 © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Java

Slide 17

Slide 17 text

Unless otherwise indicated, these slides are 
 © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Hibernate

Slide 18

Slide 18 text

Unless otherwise indicated, these slides are 
 © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data

Slide 19

Slide 19 text

Redis API

Slide 20

Slide 20 text

Redis API § 169 Commands § Full Client: 649 Methods § API grouped by features
 http://redis.io/commands

Slide 21

Slide 21 text

https://www.flickr.com/photos/darronb/6502473781

Slide 22

Slide 22 text

Key-Value API GET SET DEL EXPIRE EXPIREAT RENAME TTL TYPE

Slide 23

Slide 23 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ hello w o r l d ✕ Sequence of bytes String

Slide 24

Slide 24 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ hello w o r l d STRLEN GET SET APPEND SETRANGE GETRANGE String

Slide 25

Slide 25 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ mysequence 1 2 3 4 5 String • Integer Value INCR INCRBY DECR DECRBY

Slide 26

Slide 26 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ myfloat 1 . 2 3 4 String • Float Value INCRBYFLOAT

Slide 27

Slide 27 text

List API RPOP LPOP LREM LSET LLEN LPUSH LRANGE RPUSH BRPOP BRPOPLPUSH

Slide 28

Slide 28 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ people Alice Bob Alice ✕ Duplicates List ✕ Fast head/tail operations ✕ Ordered

Slide 29

Slide 29 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ people Alice Bob Alice List RPUSH RPOP LPUSH LPOP LRANGE LTRIM LLEN LINSERT LINDEX LSET

Slide 30

Slide 30 text

Set API SMOVE SDIFF SPOP SUNION SCARD SADD SREM SINTER SUNIONSTORE SISMEMBER

Slide 31

Slide 31 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ employees Alice Bob John ✕ Unique Set ✕ Set operations ✕ Unsorted

Slide 32

Slide 32 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Set Bob Alice John Tom SCARD SMEMBERS SADD SREM SPOP SISMEMBER SUNION SINTER SDIFF SMOVE

Slide 33

Slide 33 text

Hash API HKEYS HGET HLEN HGETALL HSET HVALS HDEL HSTRLEN HEXISTS

Slide 34

Slide 34 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ person:mark Hash ✕ Unique ✕ Map operations ✕ (Unsorted) Field Value Name Mark Ort Weinheim PLZ 69469

Slide 35

Slide 35 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ person:mark Hash Field Value Name Mark Ort Weinheim PLZ 69469 HVALS HKEYS HGETALL HLEN HGET HMGET HSET HMSET HDEL HINCRBY

Slide 36

Slide 36 text

Sorted Set API ZCARD ZSCORE ZCOUNT ZADD ZLEXCOUNT ZRANK ZINCRBY ZRANGE ZINTERSTORE

Slide 37

Slide 37 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ backlock:story Sorted Set ✕ Unique ✕ Set operations ✕ Sorted (Score) Item Score Setup 10.0 Deployment 21.2 Caching 23423

Slide 38

Slide 38 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ backlock:story Sorted Set Item Score Setup 10.0 Deployment 21.2 Caching 23423 ZADD ZRANGE ZREVRANGE ZRANGEBYLEX ZRANGEBYSCORE ZCOUNT ZLEXCOUNT ZRANK ZSCORE ZINCRBY ZCARD ZUNIONSTORE ZINTERSTORE

Slide 39

Slide 39 text

Geospatial API GEOHASH GEOADD ZREM GEODIST GEORADIUSBYMEMBER GEORADIUS

Slide 40

Slide 40 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ locations Geo-Index ✕ Unique ✕ Geo operations ✕ Unsorted Paris 48.85, 2.27 Zürich 47.37, 8.46 Köln 50.95, 6.82

Slide 41

Slide 41 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Geo-Index Frankfurt Paris Zürich GEOHASH GEOPOS ⦿ GEORADIUS GEOADD GEORADIUSBYMEMBER Mainz Winterthur ZREM GEODIST

Slide 42

Slide 42 text

Transaction API MULTI EXEC WATCH DISCARD

Slide 43

Slide 43 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ … Transactions ✕ Atomic ✕ Isolated ✕ Batch MULTI HINCRBY QUEUED GET QUEUED EXEC 1 • VALUE

Slide 44

Slide 44 text

Publish/Subscribe SUBSCRIBE PUBSUB NUMSUB PSUBSCRIBE PUBLISH UNSUBSCRIBE

Slide 45

Slide 45 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Channels Pub/Sub ✕ Transient ✕ Decoupled from Keyspace ✕ Broadcast Channel Subscribers MyChannel 5 news.it.* 7

Slide 46

Slide 46 text

Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Pub/Sub SUBSCRIBE UNSUBSCRIBE PUBLISH Channel1 Channel2 Channel* PSUBSCRIBE PUNSUBSCRIBE Subscriber Subscriber Subscriber

Slide 47

Slide 47 text

Lua Scripting EVALSHA SCRIPT KILL SCRIPT DEBUG EVAL SCRIPT LOAD

Slide 48

Slide 48 text

Resources § Slides: https://mp911.de/redis-en § Redis: http://redis.io § Code: https://github.com/mp911de/redis-intro § Jedis: https://github.com/xetorthio/jedis § lettuce: https://github.com/mp911de/lettuce § Redisson: https://github.com/mrniko/redisson § Hibernate OGM: http://hibernate.org/ogm/ § Spring Data Redis: http://projects.spring.io/spring-data-redis/

Slide 49

Slide 49 text

Learn More. Stay Connected. Twitter: @mp911de Github: github.com/mp911de Website: paluch.biz