class Ez::Settings::Backend::Redis
Constants
- NAMESPACE
- PREFIX
Attributes
connection[R]
namespace[R]
Public Class Methods
new(connection, namespace: NAMESPACE)
click to toggle source
# File lib/ez/settings/backend/redis.rb, line 14 def initialize(connection, namespace: NAMESPACE) @connection = connection @namespace = namespace end
Public Instance Methods
read()
click to toggle source
# File lib/ez/settings/backend/redis.rb, line 19 def read value = connection.get(key) value.nil? ? {} : JSON.parse(value).deep_symbolize_keys end
write(data)
click to toggle source
# File lib/ez/settings/backend/redis.rb, line 24 def write(data) new_data = read.merge(data) connection.set(key, JSON.generate(new_data)) end
Private Instance Methods
key()
click to toggle source
# File lib/ez/settings/backend/redis.rb, line 31 def key @key ||= "#{PREFIX}:#{namespace}" end