zenstruck/cache-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

zenstruck/cache-bundle

最新稳定版本:v3.0.0

Composer 安装命令:

composer require zenstruck/cache-bundle

包简介

Provides a httpcache warmup command for Symfony2

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage StyleCI Latest Stable Version License

Provides a httpcache warmup command for Symfony2. The command simply executes a GET request on a list of urls. One or more url providers must be registered. This bundle requires an implementation of php-http/httplug and php-http/message-factory.

Installation

  1. Add to your composer.json:

    $ composer require zenstruck/cache-bundle
    
  2. Register this bundle with Symfony2:

    // app/AppKernel.php
    
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Zenstruck\CacheBundle\ZenstruckCacheBundle(),
        );
        // ...
    }

Configuration

An http_client (class or service implementing Http\Client\HttpClient) and message_factory (class or service implementing Http\Message\MessageFactory) must be configured.

zenstruck_cache:
    http_client:    Acme\MyHttpClient    # or a service (acme.my_http_client)
    message_factory: Acme\MyMessageFactory # or a service (acme.my_message_factory)

HttpCache Warmup Command

Usage:

app/console zenstruck:http-cache:warmup

Sitemap Provider

This bundle comes with a URL provider that looks at a list of sitemaps to retrieve a list of urls. If a url is given without the sitemap or sitemap index, the provider first looks for a {url}/sitemap_index.xml to find a set of sitemap files. If no index is found, it defaults to using {url}/sitemap.xml.

To enable the sitemap provider, configure it in your config.yml:

zenstruck_cache:
    sitemap_provider:
        sitemaps:
            - http://example.com/sitemap.xml # detects if sitemap or sitemap index and act accordingly
            - http://example.com/en/sitemap.xml # same as above
            - http://www.example.com # trys http://example.com/sitemap_index.xml and http://example.com/sitemap.xml

Add a Custom URL Provider

  1. Create a class that implements Zenstruck\CacheBundle\Url\UrlProvider:

    use Zenstruck\CacheBundle\Url\UrlProvider;
    
    namespace Acme;
    
    class MyUrlProvider implements UrlProvider
    {
        public function getUrls()
        {
            $urls = array();
    
            // fetch from a datasource
    
            return $urls;
        }
    
        public function count()
        {
            return count($this->getUrls());
        }
    }
  2. Register the class as a service tagged with zenstruck_cache.url_provider:

    my_url_provider:
        class: Acme\MyUrlProvider
        tags:
            - { name: zenstruck_cache.url_provider }

Full Default Config

zenstruck_cache:
    # Either a class or a service that implements Http\Client\HttpClient.
    http_client:              ~ # Required

    # Either a class or a service that implements Http\Message\MessageFactory.
    message_factory:          ~ # Required

    sitemap_provider:
        enabled:              false
        sitemaps:             []

zenstruck/cache-bundle 适用场景与选型建议

zenstruck/cache-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.99k 次下载、GitHub Stars 达 39, 最近一次更新时间为 2013 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cache」 「caching」 「httpcache」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 zenstruck/cache-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 zenstruck/cache-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 zenstruck/cache-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10.99k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 39
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 39
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-30