ReqClient.Plugin.Cacher (req_client v0.1.17)

Copy Markdown View Source

Req cacher plugin

Use cache if it exists and not expired, otherwise update cache with response in status 200.

Mainly used in some rarely changed or slowly API requests.

This is not the default :cache request-step but some code from it

Support proxy value

  • :cacher boolean()
  • :cacher_dir String.t() (optional)
  • :cacher_fresh_days integer() (optional), if set <= 0 means always expired

Summary

Functions

attach(req, opts \\ [])

check_cacher(req)

enable?(req)

fresh_after_at(days \\ nil)

get_cacher_dir(cacher_dir \\ nil)

get_filet_time(path)

restore_cache(cache_path)

update_cacher(arg)

write_cache(cache_path, resp)