TeslaCache is a Basic Cache Middleware for Tesla. It will cache only GET requests for X milliseconds.
Add :tesla_cache
to your list of dependencies in mix.exs
:
def deps do
[
{:tesla_cache, "~> 1.1.0"}
]
end
defmodule GoogleClient do
use Tesla
plug Tesla.Middleware.Cache, ttl: :timer.seconds(2)
end
The source code is under the MIT License. Copyright (c) 2017- Emerson Macedo.