承接 ryssbowh/php-cache-warmer 相关项目开发

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

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

ryssbowh/php-cache-warmer

最新稳定版本:1.0.1

Composer 安装命令:

composer require ryssbowh/php-cache-warmer

包简介

An asynchronous php cache warmer

README 文档

README

Simple php cache warmer, add urls or parse sitemap and visits all the urls asynchronously. You need to wait for the promise returned by the warm method to finish :

use Ryssbowh\PhpCacheWarmer\Warmer;

$warmer = new Warmer();
$warmer->parseSitemap('http://mysite.com/sitemap.xml')
	->addUrls('http://othersite.com')
	->addUrls([
		'http://othersite.com/blog',
		'http://othersite.com/hello'
	])
	->ignoreUrls('http://mysite.com/page-503')
	->ignoreUrls([
		'http://mysite.com/page-400',
		'http://mysite.com/page-500'
	])
	->ignoreRegexs('/http:\/\/mysite\.com\/page*/')
	->ignoreRegexs([
		'/http:\/\/mysite\.com\/forum*/',
		'/http:\/\/mysite\.com\/blog*/'
	]);
$warmer->warm()->wait();

You can define the amount of concurrent requests (default 25) :

$warmer = new Warmer(50);

You can pass guzzle options in the constructor :

$warmer = new Warmer(25, ['headers' => [
	'User-Agent' => $_SERVER['HTTP_USER_AGENT'],
]]);

And subscribe an observer which will be called for every successful and failed requests :

use Ryssbowh\PhpCacheWarmer\Warmer;
use Ryssbowh\PhpCacheWarmer\Observer;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Response;

class MyObserver implements Observer
{
	public function onFulfilled(Response $response, string $url)
	{
		echo 'visited '.$url;
	}

	public function onRejected(RequestException $reason, string $url)
	{
		echo 'failed '.$url.' with code '.$reason->getResponse()->getStatusCode();
	}
}

$warmer = new Warmer(25, [], new MyObserver);

Thanks to the great vipnytt/sitemapparser sitemap parser :)

统计信息

  • 总下载量: 69.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-18