12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/models/glib/text.rb', line 12
def self.get_content(key, default_value, options:)
scope_key = "#{options[:scope]}.#{options[:lang]}.#{key}"
if content = $dt_redis.get(scope_key)
text = find_by(scope: options[:scope], lang: options[:lang], key: key)
else
if text = find_by(scope: options[:scope], lang: options[:lang], key: key)
update_content(scope_key, text.content)
content = text.content
else
text = create(scope: options[:scope], lang: options[:lang], key: key, content: default_value)
update_content(scope_key, default_value)
content = default_value
end
end
[content, text]
end
|