de cache a nosql. - qconsp.com · um banco orientado a documentos: mongodb, couchdb um cache: redis...
TRANSCRIPT
![Page 1: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/1.jpg)
decacheanosql.
https://slides.com/robertomarin/redis
https://github.com/robertomarin/redis-de-cache-a-nosql
![Page 2: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/2.jpg)
![Page 3: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/3.jpg)
![Page 4: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/4.jpg)
REDIS?REmoteDIctionaryServer
Criadoem2009por
SalvatoreSanfilippo
![Page 5: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/5.jpg)
OQUEOREDISNÃOÉ
Somenteumkey/valuestore:Memcached
Umbancodedadosrelacional:MySQL,Oracle,PostGre
Umbancoorientadoadocumentos:MongoDB,CouchDB
Umcache:RedisétãopersistentequandoPostGre->RedisPersistenceDemystified
![Page 6: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/6.jpg)
ANOTÍCIA
![Page 7: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/7.jpg)
REDISMEMCACHEMEMCACHED
![Page 8: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/8.jpg)
DOCUMENTACÃOhttp://redis.io/documentation
http://redis.io/commands
http://redis.io/clients
http://try.redis.io
![Page 9: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/9.jpg)
INSTALANDOOREDIS
Baixeaversãoatual:http://redis.io/download
Descompacte
$make$maketest$makeinstall
![Page 10: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/10.jpg)
INICIANDOOREDIS
$redis-serverredis.conf
![Page 11: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/11.jpg)
GETTINGSTARTED$_CONSOLE
INFO
GET/SET
INCR/DECR
![Page 12: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/12.jpg)
CLIENTESJAVA
Jedis(maismaduro,maisconhecido)
Redisson(interessante,diferentesfeatures)
![Page 13: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/13.jpg)
EXEMPLOS{$CODE}
Redis01.java
Redis02.java
![Page 14: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/14.jpg)
CONFIGURAÇÃO
redis.conf
redis-1200.conf
![Page 15: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/15.jpg)
REPLICAÇÃO
$SLAVEOFhostport
![Page 16: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/16.jpg)
SHARDING
Oqueésharding?
Quandodevousarsharding?
![Page 17: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/17.jpg)
SHARDING
ConfiguraçõesdosShards
IniciarosShards
Exemplo:
Redis03Sharding.java
![Page 18: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/18.jpg)
ISTHISREALLIFE?
![Page 19: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/19.jpg)
CEP-CÓDIGOPOSTAL
BaseemMySQL
CachecomRedis
CepTest.java
Performance?!~
![Page 20: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/20.jpg)
CEPDAOCOMREDISantesDeIrNoBanco()
tentarecuperardoredis;
senãofornulotransformaemobjeto;retornaobjeto;senãorecuperadobanco;transformaemstring(json);armazenanoredis;retornaobjeto;CepRedisDaoTest.java
![Page 21: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/21.jpg)
OQUETEMDEBOM?
temosumcache:)
OQUETEMDERUIM?
acoplamento:(umaclasseextra;@
![Page 22: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/22.jpg)
QUEMPODERÁNOSDEFENDER?
![Page 23: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/23.jpg)
AOPaspectorientedprogramming
![Page 24: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/24.jpg)
MASOQUEÉAOPMESMO?
![Page 25: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/25.jpg)
SQL+REDIS+AOP
Lembrando,estamosresolvendo:acoplamento:(umaclasseextra;@
CepAopTest.java
![Page 26: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/26.jpg)
OQUETEMDEBOM?
únicocódigoparatodos:Dpoucoacoplamento;P
OQUETEMDERUIM?pointcutnãoétãocustomizável=(eseeuquisercolocarumexpires:@
![Page 27: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/27.jpg)
SQL+REDIS+AOP+@ANNOTATION
=POWER
![Page 28: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/28.jpg)
SQL+REDIS+AOP+@ANNOTATION
CepAopTest.javaRedisAnnotationAspect.java
![Page 29: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/29.jpg)
OQUETEMDEBOM?
únicocódigoparatodos:Dpoucoacoplamento;Pexpireseoutrasfeatures=)
OQUETEMDERUIM?nãosei,maspodeficarmelhor!
![Page 30: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/30.jpg)
ESEAFONTEDEDADOSCAIR?
webservice
bancodedados
![Page 31: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/31.jpg)
COMOOCACHEPODENOSAJUDAR?emvezdeguardarmosapenasoobjetonoredis
![Page 32: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/32.jpg)
NÓSGUARDAMOSUMENVELOPEquetemoobjetodentro!:D
![Page 33: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/33.jpg)
SQL+REDIS+AOP+@ANNOTATION+HA
RedisAnnotationHAAspect.java
![Page 34: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/34.jpg)
ÉCERTOFAZERISSO?
![Page 35: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/35.jpg)
AGORAQUEAGENTEFEZTUDOISSO...
PorquenãodeixartodaabasedeCEPsnoRedis?
Éconfiável?
![Page 36: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/36.jpg)
OUTRASESTRUTURASCOMREDIS
HASHES
LISTS
SETS
SORTEDSETS
![Page 37: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/37.jpg)
+ =
![Page 38: de cache a nosql. - qconsp.com · Um banco orientado a documentos: MongoDB, CouchDB Um cache: Redis é tão persistente quando PostGre-> Redis Persistence Demystified. A NOTÍCIA](https://reader030.vdocuments.net/reader030/viewer/2022021519/5be5b01809d3f2580c8c2329/html5/thumbnails/38.jpg)