Share
Embed
Hallo, ich bin Redis (JUG Saxony Day 2016)
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.
Mark Paluch
September 30, 2016
Transcript
47 slides
-
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 -
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 -
Überblick § 100% Open Source § Treiberentwicklung durch Community §
In-Memory Operationen § Persistenz: Append Only File und Snapshots -
Redis Setup $ wget http://download.redis.io/releases/ redis-3.2.4.tar.gz | tar xzf -
$ make -C redis-3.2.4 $ docker run --name redis -d redis:alpine $ apt-get/brew install redis-server -
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 -
Betrieb von Redis § Redis Standalone (Single-Node, Master-Slave) § Redis
Sentinel (Master/Slave Failover) § Redis Cluster (Sharding, Slaves) -
Redis Use-Cases § Key-Value store § Caching § Queueing §
High-speed data ingestion § Verteilte Sessions § Verteilte Locks § Real-Time Analytics § Geo-Indexing -
Redis: Datastructure Server § Key-Value § Hashes § Lists §
Sorted Sets § Geospatial Index § Publish/Subscribe § HyperLogLog § Transactions § Scripting -
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: Foo key: people:7 field value firstname Foo -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 Pattern PSUBSCRIBE PUNSUBSCRIBE Subscriber Subscriber Subscriber -
List API RPOP LPOP LREM LSET LLEN LPUSH LRANGE RPUSH
BRPOP BRPOPLPUSH -
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 ✕ Sortiert -
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 -
Set API SMOVE SDIFF SPOP SUNION SCARD SADD SREM SINTER
SUNIONSTORE SISMEMBER -
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 -
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 -
Sorted Set API ZCARD ZSCORE ZCOUNT ZADD ZLEXCOUNT ZRANK ZINCRBY
ZRANGE ZINTERSTORE -
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 -
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 -
Ressourcen § Slides: https://mp911.de/redis-jsd § Code: https://github.com/mp911de/redis-intro § Redis: http://redis.io
§ 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/