Last active
August 8, 2023 05:52
-
-
Save djburdick/5027494 to your computer and use it in GitHub Desktop.
Redis rails commands. #rails #redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
# | |
# Strings | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment