承接 rtheunissen/guzzle-cache-handler 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rtheunissen/guzzle-cache-handler

最新稳定版本:v2.0.0

Composer 安装命令:

composer require rtheunissen/guzzle-cache-handler

包简介

Guzzle 6/7 handler used to cache responses

README 文档

README

Author License Latest Version Build Status Scrutinizer Scrutinizer Coverage

Installation

composer require rtheunissen/guzzle-cache-handler

Usage

This is a handler which caches responses for a given amount of time.

You will need an implemented CacheInterface. See rtheunissen/cache for more details.

use Concat\Http\Handler\CacheHandler;
use Doctrine\Common\Cache\FilesystemCache;
use GuzzleHttp\Client;

// Basic directory cache example
$cacheProvider = new FilesystemCache(__DIR__ . '/cache');

// Guzzle will determine an appropriate default handler if `null` is given.
$defaultHandler = null;

// Create a cache handler with a given cache provider and default handler.
$handler = new CacheHandler($cacheProvider, $defaultHandler, [

    /**
     * @var array HTTP methods that should be cached.
     */
    'methods' => ['GET', 'HEAD', 'OPTIONS'],

    /**
     * @var integer Time in seconds to cache a response for.
     */
    'expire' => 60,

    /**
     * @var callable Accepts a request and returns true if it should be cached.
     */
    'filter' => null,
]);

// Use a PSR-3 compliant logger to log when bundles are stored or fetched.
$handler->setLogger($logger);

// Create a Guzzle 6/7 client, passing the cache handler as 'handler'.
$client = new Client([
    'handler' => $handler
]);

统计信息

  • 总下载量: 140.74k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-05