Faraday Http Cache

我要开发同款
匿名用户2015年05月07日
84阅读

技术信息

授权协议
Apache

作品详情

FaradayHttpCache是一个Faraday的扩展,实现了HTTP的缓存。通过检查过期时间来验证已存储的响应信息。

使用方法:

cliet = Faraday.ew do |builder|  builder.use :http_cache, store: Rails.cache  # or  builder.use Faraday::HttpCache, store: Rails.cache  builder.adapter Faraday.default_adaptered

使用Memcached:

# Coect the middleware to a Memcache istace.store = ActiveSupport::Cache.lookup_store(:mem_cache_store, ['localhost:11211'])cliet = Faraday.ew do |builder|  builder.use :http_cache, store: store  builder.adapter Faraday.default_adaptered# Or use the Rails.cache istace iside your Rails app.cliet = Faraday.ew do |builder|  builder.use :http_cache, store: Rails.cache  builder.adapter Faraday.default_adaptered

日志:

cliet = Faraday.ew do |builder|  builder.use :http_cache, store: Rails.cache, logger: Rails.logger  builder.adapter Faraday.default_adapteredcliet.get('https://site/api/users')# logs "HTTP Cache: [GET users] miss, store"

功能介绍

Faraday Http Cache 是一个 Faraday 的扩展,实现了 HTTP 的缓存。通过检查过期时间来验证已存储的响应信息。 使用方法: client = Faraday.new d...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论