Refactor view cache
This commit is contained in:
@@ -12,15 +12,20 @@ module Adamantium
|
|||||||
|
|
||||||
data = JSON.generate(expire: expiry.to_i, content: rendered_content)
|
data = JSON.generate(expire: expiry.to_i, content: rendered_content)
|
||||||
|
|
||||||
path = "#{key}.json"
|
write(key: key, content: data)
|
||||||
|
|
||||||
File.write(File.join(Hanami.app.root, "tmp", path), data)
|
|
||||||
|
|
||||||
rendered_content
|
rendered_content
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def write(key:, content:)
|
||||||
|
filename = "#{key}.json"
|
||||||
|
path = File.join(Hanami.app.root, "tmp", filename)
|
||||||
|
|
||||||
|
File.write(path, content)
|
||||||
|
end
|
||||||
|
|
||||||
def read(key:)
|
def read(key:)
|
||||||
filename = "#{key}.json"
|
filename = "#{key}.json"
|
||||||
path = File.join(Hanami.app.root, "tmp", filename)
|
path = File.join(Hanami.app.root, "tmp", filename)
|
||||||
|
Reference in New Issue
Block a user