Skip to content

Instantly share code, notes, and snippets.

@carlossanchezp
Created May 10, 2015 17:51
Show Gist options
  • Save carlossanchezp/2493b0579c0fdc4dfb38 to your computer and use it in GitHub Desktop.
Save carlossanchezp/2493b0579c0fdc4dfb38 to your computer and use it in GitHub Desktop.
Rails.redis.get(key)
Rails.redis.set(key, value)
Rails.redis.expire(key, 1.hour)
Rails.redis.del(key)
Rails.redis.sadd(set_name, value)
Rails.redis.srem(set_name, key)
Rails.redis.sismember(set_name, value) # boolean test to see if val exists
Rails.redis.spop(set_name) # removes and returns a random set element
Rails.redis.smembers(set_name)
Rails.redis.hset(hash_name, key, value)
Rails.redis.hvals(hash_name) # returns all hash values
Rails.redis.hgetall(hash_name) # returns all key and values
Rails.redis.hget(hash_name, key)
Rails.redis.hdel(hash_name, key)
Rails.redis.hincrby(hash_name, key, 1) # increments hash value by int number
Rails.redis.hexists(hash_name, key)
Rails.redis.lpop(list)
Rails.redis.rpush(list, value)
Rails.redis.publish(channel, data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment