定制 peroks/guzzle-file-cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

peroks/guzzle-file-cache

最新稳定版本:2.0.0

Composer 安装命令:

composer require peroks/guzzle-file-cache

包简介

A lightweight file cache for Guzzle 7+ implementing the PSR-16 Caching Interface

README 文档

README

A lightweight file cache for Guzzle 7+ implementing the PSR-16 Caching Interface

How to use

<?php

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Peroks\GuzzleFileCache\Cache;
use Peroks\GuzzleFileCache\FileStorage;

function getGuzzleClient( array $options = [] ): Client {
    $stack = HandlerStack::create();
    $store = new FileStorage( 'your/cache/directory' );
    $cache = new Cache( $store );

    $stack->push( $cache );
    $options['handler'] = $stack;

    return new Client( $options );
}

You use an instance of the Peroks\GuzzleFileCache\Cache class to add file-caching as a handler (middleware) to the Guzzle http client.

Peroks\GuzzleFileCache\FileStorage does the real work, implementing the PSR-16: Common Interface for Caching Libraries.

After you have added caching to the Guzzle http client, there is a new option for caching: ttl (time-to-live). The ttl value is in seconds.

You can set this option for each request sent through the client. If you omit this option or set ttl to 0, the request is not cached.

$response = $client->send( $request, [ 'ttl' => 3600 ] ); // 1 hour caching.

Installing

You need composer to download and install peroks/guzzle-file-cache. Just run composer require peroks/guzzle-file-cache in your project.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固