Allow custom cache expiry
This commit is contained in:
@@ -22,8 +22,8 @@ module Adamantium
|
||||
handle_exception ROM::TupleCountMismatchError => :not_found
|
||||
handle_exception StandardError => :handle_error
|
||||
|
||||
def cache(key:, content:)
|
||||
cacher.call(key: key, content: content, expiry: TimeMath.min.advance(Time.now, +10))
|
||||
def cache(key:, content_proc:, expiry: TimeMath.min.advance(Time.now, +10))
|
||||
cacher.call(key: key, content_proc: content_proc, expiry: expiry)
|
||||
end
|
||||
|
||||
def not_found(_req, res, _exception)
|
||||
|
@@ -7,7 +7,7 @@ module Adamantium
|
||||
include Deps["views.recently_played.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.body = cache(key: "recently_played", content: index.call.to_str)
|
||||
res.body = cache(key: "recently_played", content_proc: -> { index.call.to_str })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user