项目作者: amphp

项目描述 :
An async HTTP cache for Amp's HTTP client.
高级语言: PHP
项目地址: git://github.com/amphp/http-client-cache.git
创建时间: 2019-07-01T19:39:14Z
项目社区:https://github.com/amphp/http-client-cache

开源协议:MIT License

下载


http-client-cache

License

This package provides an HTTP cache in form of an ApplicationInterceptor for Amp’s HTTP client based on RFC 7234.

Features

  • Private cache (SingleUserCache)
  • Automatic vary header support
  • Caching pushed responses

Planned Features

  • Shared cache
  • Conditional requests

Installation

This package can be installed as a Composer dependency.

  1. composer require amphp/http-client-cache

Usage

Currently, only a SingleUserCache is provided.
Therefore, it is unsafe to use a single instance for multiple users, e.g. different access tokens.

  1. use Amp\Cache\FileCache;
  2. use Amp\Http\Client\HttpClientBuilder;
  3. use Amp\Http\Client\Cache\SingleUserCache;
  4. use Amp\Sync\LocalKeyedMutex;
  5. $cache = new FileCache(__DIR__, new LocalKeyedMutex);
  6. $client = (new HttpClientBuilder)
  7. ->intercept(new SingleUserCache($cache, $logger))
  8. ->build();

Examples

More extensive code examples reside in the examples directory.

Versioning

amphp/http-client-cache follows the semver semantic versioning specification like all other amphp packages.

Security

If you discover any security related issues, please email me@kelunik.com instead of using the issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.