Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
REDIS NO ES
SOLO UNA
CACHÉ
¿QUÉ VAMOS A VER HOY?
¿Qué es Redis?
Operaciones y tipos de datos
Retwis in C#
ALGUNOS DATOS
Redis = REmote DIctionary Server
La primera release en 2009
Open Source, Licencia BSD
La versión más rec...
Sistema de almacenamiento
y caché avanzado que usa datos de tipo
clave - valor
Una clave puede contener
strings, hashes, lists,
sets, sorted sets,
bitmaps y hyperloglogs
REDIS
 Redis trabaja in-memory pero persiste en disco
 1 millón de pequeñas “Key - String” usan ~ 100 MB de memoria
 Un...
DIFERENCIAS CON MEMCACHED
 Memcached es un “Sistema de cache en memoria distribuido”
 Redis persiste los datos en el dis...
OPERACIONES y
TIPOS DE DATOS
BASIC
 SET key value [EX seconds] [PX milliseconds] [NX|XX]
 GET key
 DEL key
BASIC
 EXISTS key
 KEYS pattern
 EXPIRE key seconds
 MGET key [key …]
 MSET key value [key value …]
CADENAS
 STRLEN KEY
 APPEND key value
ENTEROS
 INCR key / INCRBY key increment
 DECR key / DECRBY key increment
HASHES
 HSET key field value
 HGET key field
 HGETALL key
 HDEL key field [field …]
LISTAS
 LSET key index value
 LPUSH key value [value …] / RPUSH key value [value …]
 LPOP key / RPOP key
 LRANGE key s...
SETS
 SADD key member [member …]
 SMEMBERS key / SRANDMEMBER key [count]
 SSCAN key cursor [MATCH pattern] [COUNT count...
OPERACIONES CON SETS
 SINTER key [key …] / SINTERSTORE destination key [key …]
 SDIFF key [key …] / SDIFFSTORE destinati...
SORTED SETS
 ZADD key score member [score member …]
 ZSCORE key member
 ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT o...
HYPERLOGLOG
“Hyperloglog es una técnica aproximada para
calcular el número de entradas distintas en un
conjunto (cardinali...
HyperLogLog
 PFADD key element [element …]
 PFCOUNT key [key …]
 PFMERGE destkey sourcekey [sourcekey ...]
 Caso de us...
PUB/SUB
 SUBSCRIBE channel [channel …]
 UNSUBSCRIBE [channel [channel …]]
 PUBLISH channel message
TRANSACCIONES
 MULTI
 EXEC
 DISCARD
TRANSACCIONES
WATCH mykey
val = GET mykey
val = val + 1
MULTI
SET mykey $val
EXEC
SCRIPTING
Ejecutar scripts LUA en lado servidor
 EVAL script numkeys key [key ...] arg [arg …]
 SCRIPT LOAD script
 EVA...
CASOS DE USO
 Listados de últimos xxx: LPUSH y LTRIM
 Tablas de top o de rankings: ZADD, ZREVRANGE y ZREVRANGEBYSCORE
 ...
EN RESUMEN
 Maneja cadenas de texto (o byte arrays)
 5 tipos de datos: Keys, Hashes, Lists, Sets, Sorted Sets,
 Pub/Sub...
MÁS INFORMACIÓN
 A basic redis client for .NET
https://github.com/fernandoescolar/Tokiota.Redis
 Documentación Redis
htt...
www.catdotnet.net
Upcoming SlideShare
Loading in …5
×

Redis no es solo una caché

641 views

Published on

Presentación utilizada para introducir las operaciones y tipos de datos básicos de Redis.

Published in: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Redis no es solo una caché

  1. 1. REDIS NO ES SOLO UNA CACHÉ
  2. 2. ¿QUÉ VAMOS A VER HOY? ¿Qué es Redis? Operaciones y tipos de datos Retwis in C#
  3. 3. ALGUNOS DATOS Redis = REmote DIctionary Server La primera release en 2009 Open Source, Licencia BSD La versión más reciente: 3.0 Escrito en C Tiene librerías para +30 lenguajes Buena documentación
  4. 4. Sistema de almacenamiento y caché avanzado que usa datos de tipo clave - valor
  5. 5. Una clave puede contener strings, hashes, lists, sets, sorted sets, bitmaps y hyperloglogs
  6. 6. REDIS  Redis trabaja in-memory pero persiste en disco  1 millón de pequeñas “Key - String” usan ~ 100 MB de memoria  Un solo hilo de ejecución (la CPU no será el cuello de botella)  Un sistema normal Linux puede enviar 500k requests/segundo  El límite de almacenamiento es la memoria disponible  máx. 232 keys
  7. 7. DIFERENCIAS CON MEMCACHED  Memcached es un “Sistema de cache en memoria distribuido”  Redis persiste los datos en el disco de forma eventual  Memcached es un sistema caché LRU (Least Recently Used)  Redis tiene diferentes tipos de datos y features  Memcached es multihilo  Velocidad similar (en local)
  8. 8. OPERACIONES y TIPOS DE DATOS
  9. 9. BASIC  SET key value [EX seconds] [PX milliseconds] [NX|XX]  GET key  DEL key
  10. 10. BASIC  EXISTS key  KEYS pattern  EXPIRE key seconds  MGET key [key …]  MSET key value [key value …]
  11. 11. CADENAS  STRLEN KEY  APPEND key value
  12. 12. ENTEROS  INCR key / INCRBY key increment  DECR key / DECRBY key increment
  13. 13. HASHES  HSET key field value  HGET key field  HGETALL key  HDEL key field [field …]
  14. 14. LISTAS  LSET key index value  LPUSH key value [value …] / RPUSH key value [value …]  LPOP key / RPOP key  LRANGE key start stop  LREM key count value
  15. 15. SETS  SADD key member [member …]  SMEMBERS key / SRANDMEMBER key [count]  SSCAN key cursor [MATCH pattern] [COUNT count]  SISMEMBER key member  SPOP key  SREM key member [member …]
  16. 16. OPERACIONES CON SETS  SINTER key [key …] / SINTERSTORE destination key [key …]  SDIFF key [key …] / SDIFFSTORE destination key [key …]  SUNION key [key …] / SUNIONSTORE destination key [key …]
  17. 17. SORTED SETS  ZADD key score member [score member …]  ZSCORE key member  ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset  count]  ZREM key member [member ...]  ZREMRANGEBYLEX key min max  ZINCRBY key increment member
  18. 18. HYPERLOGLOG “Hyperloglog es una técnica aproximada para calcular el número de entradas distintas en un conjunto (cardinalidad).” Para conseguir el 99% de precision, se necesitan solo 16 Kb.
  19. 19. HyperLogLog  PFADD key element [element …]  PFCOUNT key [key …]  PFMERGE destkey sourcekey [sourcekey ...]  Caso de uso: Track Unique Visitors
  20. 20. PUB/SUB  SUBSCRIBE channel [channel …]  UNSUBSCRIBE [channel [channel …]]  PUBLISH channel message
  21. 21. TRANSACCIONES  MULTI  EXEC  DISCARD
  22. 22. TRANSACCIONES WATCH mykey val = GET mykey val = val + 1 MULTI SET mykey $val EXEC
  23. 23. SCRIPTING Ejecutar scripts LUA en lado servidor  EVAL script numkeys key [key ...] arg [arg …]  SCRIPT LOAD script  EVALSHA sha1 numkeys key [key ...] arg [arg ...]
  24. 24. CASOS DE USO  Listados de últimos xxx: LPUSH y LTRIM  Tablas de top o de rankings: ZADD, ZREVRANGE y ZREVRANGEBYSCORE  Cálculos de tipo “karma”: ZADD, ZRANK, ZINCRBY  Contadores usuarios activos: INCR y EXPIRE  Publicación y suscripción: mediator  Colas: BLPOP y LPUSH  Textos auto-completables: ZADD, ZRANK y ZRANGE  Almacenar información que caduca: EXPIRE
  25. 25. EN RESUMEN  Maneja cadenas de texto (o byte arrays)  5 tipos de datos: Keys, Hashes, Lists, Sets, Sorted Sets,  Pub/Sub  Operaciones con datos  Scripts en LUA  En memoria, pero persiste en forma de snapshots
  26. 26. MÁS INFORMACIÓN  A basic redis client for .NET https://github.com/fernandoescolar/Tokiota.Redis  Documentación Redis http://redis.io/documentation  ServiceStack https://servicestack.net  Ejemplo de uso Redis Bitmaps http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps
  27. 27. www.catdotnet.net

×