Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hallo, ich bin Redis

Hallo, ich bin Redis

Caching? Verteile Sessions? Pub/Sub? 100.000 Requests pro Sekunde? Dies und viel mehr bietet Redis. Redis ist ein vielseitiger Open Source NoSQL Data Store der sich einer immer größeren Beliebtheit erfreut. Der Vortrag ist eine Einführung in Redis und veranschaulicht mit Hilfe von Code-Beispielen, wie Redis mit Spring Data, Hibernate OGM und plain Java verwendet werden kann.

C5f6e8dffbb19acf405198c8fb917337?s=128

Mark Paluch

May 17, 2016
Tweet

More Decks by Mark Paluch

Other Decks in Technology

Transcript

  1. Hallo, ich bin 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
  2. 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
  3. Remote Dictionary Server

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

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

  6. Überblick § 100% Open Source § Treiberentwicklung durch Community §

    In-Memory Operationen § Append Only File und Snapshots
  7. 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
  8. 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 Konsole Demo
  9. Betrieb von Redis § Redis Standalone (Single-Node, Master-Slave) § Redis

    Sentinel (Master/Slave Failover) § Redis Cluster (Sharding, Slaves)
  10. Redis Sicherheit § Nur hinter Firewall betreiben § Passwort-Authentifikation §

    SSL (mit stunnel)
  11. https://www.flickr.com/photos/beckyjohns/4629502158 Use-Cases

  12. Redis Use-Cases § Key-Value store § Caching § Queues §

    High-speed data ingestion § Verteilte Sessions § Verteilte Locks § Real-Time Analytics § Geo-Indexing
  13. Redis: Datastructure Server § Key-Value § Hashes § Lists §

    Sorted Sets § Geospatial Index
 § Publish/Subscribe § HyperLogLog § Transactions § Scripting
  14. 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
  15. Clients

  16. 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
  17. 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
  18. 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
  19. Redis API

  20. Redis API § 169 Commands § Full Client: 649 Methoden

    § API Gruppierung nach Features 
 http://redis.io/commands
  21. https://www.flickr.com/photos/darronb/6502473781

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

  23. 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 ✕ Bytesequenz String
  24. 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
  25. 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-Wert INCR INCRBY DECR DECRBY
  26. 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 • Double-Wert INCRBYFLOAT
  27. List API RPOP LPOP LREM LSET LLEN LPUSH LRANGE RPUSH

    BRPOP BRPOPLPUSH
  28. 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 ✕ Duplikate Liste ✕ Schnelle Head/Tail Operationen ✕ Reihenfolge
  29. 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 Liste RPUSH RPOP LPUSH LPOP LRANGE LTRIM LLEN LINSERT LINDEX LSET
  30. Set API SMOVE SDIFF SPOP SUNION SCARD SADD SREM SINTER

    SUNIONSTORE SISMEMBER
  31. 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 ✕ Eindeutig Set ✕ Set Operationen ✕ Unsortiert
  32. 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
  33. Hash API HKEYS HGET HLEN HGETALL HSET HVALS HDEL HSTRLEN

    HEXISTS
  34. 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 ✕ Eindeutig ✕ Map Operationen ✕ (Unsortiert) Field Value Name Mark Ort Weinheim PLZ 69469
  35. 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
  36. Sorted Set API ZCARD ZSCORE ZCOUNT ZADD ZLEXCOUNT ZRANK ZINCRBY

    ZRANGE ZINTERSTORE
  37. 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 ✕ Eindeutig ✕ Set Operationen ✕ Sortiert (Score) Item Score Setup 10.0 Deployment 21.2 Caching 23423
  38. 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
  39. Geospatial API GEOHASH GEOADD ZREM GEODIST GEORADIUSBYMEMBER GEORADIUS

  40. 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 ✕ Eindeutig ✕ Geo Operationen ✕ Unsortiert Paris 48.85, 2.27 Zürich 47.37, 8.46 Köln 50.95, 6.82
  41. 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
  42. Transaction API MULTI EXEC WATCH DISCARD

  43. 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 ✕ Atomar ✕ Isolation ✕ Batch MULTI HINCRBY QUEUED GET QUEUED EXEC 1 • VALUE
  44. Publish/Subscribe SUBSCRIBE PUBSUB NUMSUB PSUBSCRIBE PUBLISH UNSUBSCRIBE

  45. 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 ✕ Unabhängig vom Keypace ✕ Broadcast Channel Subscribers MyChannel 5 news.it.* 7
  46. 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
  47. Lua Scripting EVALSHA SCRIPT KILL SCRIPT DEBUG EVAL SCRIPT LOAD

  48. Ressourcen § Slides: https://mp911.de/redis-de § 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/
  49. Learn More. Stay Connected. Twitter: @mp911de Github: github.com/mp911de Website: paluch.biz