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

Meetup (Ruby Monterrey) : NoSQL & Ruby (but mostly Redis)

Meetup (Ruby Monterrey) : NoSQL & Ruby (but mostly Redis)

Brief talk about the three main NOSQL databases in the environment with an insight into working with Redis

Adrian Cuadros

February 25, 2015
Tweet

More Decks by Adrian Cuadros

Other Decks in Programming

Transcript

  1. The three darlings of NOSQL 2 Mongo Redis Cassandra •

    Documents • JSON • JS Queries • Performance > Features • Text Search • Key-Value • Super Fast • Data Structures FTW! • Scripts en LUA • Transaccional • Columns • Huge Datasets • CQL3 ~SQL (no joins,fn) • Map/Reduce -> Hadoop • Key/KeyRange Queries Similares casos de uso que RDBMS. + Sin columnas predefinidas Real time apps Memcache Replacement Analytics Logging
  2. Mongo Redis Cassandra Hit me with tha gems Mongoid (https://github.com/mongoid/mongoid)

    Redis-RB (https://github.com/redis/redis-rb) ORM (AR Replacement) Basic Driver Cequel https://github.com/cequel/cequel) ORM (AR Replacement)
  3. 1 REDIS Estructuras de datos require 'redis' redis = Redis.new

    ## Strings redis.set "city", "monterrey" # => "OK" redis.set "temp", 3 # => OK redis.incr "temp" # => 4 redis.decrby "temp", 10 # => -6 redis.get "city" # => monterrey redis.get "temp" # => -6
  4. 1 REDIS Estructuras de datos ## Hashes redis.hset "person", "age",

    29 # => true redis.hset "person", "name", "adrian" # => true redis.hset "person", "nationality", "bolivia" # => true redis.hget "person", "name" # => adrian redis.hgetall "person" # => {"age"=>"29", "name"=>"adrian", "nationality"=>"bolivia"} redis.hmget "person", "name", "age" # => ["adrian", "29"] redis.hlen "person" # => 3
  5. 1 REDIS Estructuras de datos ## Lists redis.lpush "tasks", "cook"

    # => 1 redis.lpush "tasks", "homework" # => 2 redis.rpush "tasks", "procrastinate" redis.lpop "tasks" # => homework redis.llen "tasks" # => 2
  6. 1 REDIS Estructuras de datos ## Sets (Sin miembros repetidos)

    redis.sadd "aventones", "alberto" # => true redis.sadd "aventones", "cristina" # => true redis.sadd "reserbus", "adrian" # => true redis.sadd "reserbus", "heaney" # => true redis.sadd "reserbus", "adrian" # => false redis.sunion "reserbus", "aventones" # => ["adrian", "alberto"...]
  7. 1 REDIS Estructuras de datos ## Sorted Sets (Sets con

    scores) redis.zadd "clubes", 2, "Barcelona" redis.zadd "clubes", 3, "Chelsea" redis.zadd "clubes", 1, "Real Madrid" redis.zrange "clubes", 0, -1 # => [Real Madrid, Barcelona, Chelsea] redis.zscore "clubes", "Real Madrid" # => 1 redis.zrevrangebyscore "clubes", 3, 0 # => [Clelsea, Barcelona, Real Madrid]