定制 bigyouth/page-cache-bundle 二次开发

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

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

bigyouth/page-cache-bundle

Composer 安装命令:

composer require bigyouth/page-cache-bundle

包简介

README 文档

README

Maintainability Issues Downloads Release
Maintainability Issues Downloads Release

What is it ?

This bundle provides a simple page caching solution working as an in-app reverse proxy.

Requirements

"php": "^5.3.9|^7.0",
"symfony/cache": "^3.1"

Installation

Download the bundle

Download composer at https://getcomposer.org/download/

composer require bigyouth/page-cache-bundle

Register the bundle

Enable the bundle by adding it to the bundles array of the registerBundles method in your project's app/AppKernel.php file :

<?php

# app/AppKernel.php

// ...

class AppKernel extends Kernel
{
        public function registerBundles()
        {
            $bundles = [
                // ...

                new Bigyouth\BigyouthPageCacheBundle\BigyouthPageCacheBundle(),
            ];

            // ...
        }

        // ...
}

Configuration

Here is the default bundle configuration :

# app/config/config.yml


bigyouth_page_cache:
    enabled: false
    ttl: 300
    type: "filesystem"
    exclude: []

enabled

default : false

Set to true to enable the bundle.

ttl

default : 300

Cache lifetime. This value varies by +5%/-5% to avoid multiple caches to expire at the same time.

type

default: filesystem

Two value can be set for this parameter : filesystem and redis.

If you use filesystem, the cache will be written in the cache folder : var/cache/by_cache.

exclude

default : empty array

This parameter allows you to define url schemes that will be excluded from the page caching.

ex :

exclude:
    - "app_dev.php"
    - "back"
    - "login"
    - "logout"
    - "login_check"

Every url that contains one of the terms above will not be processed by the BigyouthPageCacheBundle.

redis_host

default : localhost

Redis host. This parameter is only used when the type parameter is set to redis.

redis_port

default : 6379

Redis port. This parameter is only used when the type parameter is set to redis.

Usage

Caching

To use the BigyouthPageCacheBundle, your controller must extend the PageCacheController.php class and use the render function :

<?php

// ...

class AcmeController extends PageCacheController
{

        // ...
        public function indexAction(Request $request)
        {

            // ...

            return $this->render('FrontBundle:Page:index.html.twig');

        }
}

The PageCacheController rewrites the render function to manage and render cache data. All of your controller actions that use the render function will be cached.

Cache invalidation

The BigyouthPageCacheBundle uses cache tags to identify your cache data. The tags are defined by the url scheme of the cached page.

For example, the page behind /products/list/my-product will be tagged with products, list and my-product.

Therefore you can invalidate a product page by doing the following in your controller :

// ...

$this->get('by.page_cache')->invalidate(["my-product"]);

// ...

or if you want to invalidate all product pages :

// ...

$this->get('by.page_cache')->invalidate(["products"]);

// ...

Authors

  • Alexis Smadja - Initial work - Alxss

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-17