class Twitch::Bot::Memory::Redis
Implement persistent memory based on Redis
Attributes
client[R]
redis[R]
Public Class Methods
new(client:)
click to toggle source
# File lib/twitch/bot/memory/redis.rb, line 10 def initialize(client:) @client = client @redis = connect_db end
Public Instance Methods
retrieve(key)
click to toggle source
# File lib/twitch/bot/memory/redis.rb, line 19 def retrieve(key) redis.get(key) end
store(key, value)
click to toggle source
# File lib/twitch/bot/memory/redis.rb, line 15 def store(key, value) redis.set(key, value) end
Private Instance Methods
connect_db()
click to toggle source
# File lib/twitch/bot/memory/redis.rb, line 27 def connect_db url = redis_config_url || ENV["REDIS_URL"] ::Redis.new(url: url) end
redis_config_url()
click to toggle source
# File lib/twitch/bot/memory/redis.rb, line 32 def redis_config_url config = client.config if config.setting("redis_host") host = config.setting("redis_host") || "localhost" port = config.setting("redis_port") || 6379 "redis://#{host}:#{port}" end end