承接 spatie/laravel-partialcache 相关项目开发

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

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

spatie/laravel-partialcache

最新稳定版本:1.3.0

Composer 安装命令:

composer require spatie/laravel-partialcache

包简介

Blade directive to cache rendered partials in laravel

README 文档

README

???? THIS PACKAGE HAS BEEN ABANDONED ????

We don't use this package anymore in our own projects and cannot justify the time needed to maintain it anymore. That's why we have chosen to abandon it. Feel free to fork our code and maintain your own copy.

Laravel Cache Partial Blade Directive

Latest Version on Packagist Software License Quality Score StyleCI Total Downloads

This package provides a Blade directive for Laravel >=5.1 to cache rendered partials in Laravel.

Install

You can install the package via Composer:

$ composer require spatie/laravel-partialcache

In Laravel 5.5 the package's service provider and facade will be registered automatically. In older versions of Laravel, you must register them manually:

// config/app.php  'providers' => [  ...  Spatie\PartialCache\PartialCacheServiceProvider::class, ],  'aliases' => [  ...  'PartialCache' => Spatie\PartialCache\PartialCacheFacade::class, ],

The facade is optional, but the rest of this guide assumes you're using it.

Optionally publish the config files:

$ php artisan vendor:publish --provider="Spatie\PartialCache\PartialCacheServiceProvider"

Usage

The package registers a blade directive, @cache. The cache directive accepts the same arguments as @include, plus optional parameters for the amount of minutes a view should be cached for, a key unique to the rendered view, and a cache tag for the rendered view. If no minutes are provided, the view will be remembered until you manually remove it from the cache.

Note that this caches the rendered html, not the rendered php like blade's default view caching.

{{-- Simple example --}} @cache('footer.section.partial') {{-- With extra view data --}} @cache('products.card', ['product' => $category->products->first()]) {{-- For a certain time --}} {{-- (cache will invalidate in 60 minutes in this example, set null to remember forever) --}} @cache('homepage.news', null, 60) {{-- With an added key (cache entry will be partialcache.user.profile.{$user->id}) --}} @cache('user.profile', null, null, $user->id) {{-- With an added tag (only supported by memcached and others) }} @cache('user.profile', null, null, $user->id, 'userprofiles') {{-- With array of tags (only supported by memcached and others) }} @cache('user.profile', null, null, $user->id, ['user', 'profile', 'location']) 

Clearing The PartialCache

You can forget a partialcache entry with PartialCache::forget($view, $key).

PartialCache::forget('user.profile', $user->id);

If you have used @cache on an entry along with tags and your cache driver supports them (like memcached and other), you need to use the same tags to forget the entry.

// With an added tag PartialCache::forget('user.profile', $user->id, 'userprofiles');  // With array of tags PartialCache::forget('user.profile', $user->id, ['user', 'profile', 'location']);

If you want to flush all entries, you'll need to either call PartialCache::flush() (note: this is only supported by drivers that support tags), or clear your entire cache.

Configuration

Configuration isn't necessary, but there are three options specified in the config file:

  • partialcache.enabled: Fully enable or disable the cache. Defaults to true.
  • partialcache.directive: The name of the blade directive to register. Defaults to cache.
  • partialcache.key: The base key that used for cache entries. Defaults to partialcache.
  • partialcache.default_duration: The default cache duration in minutes, set null to remember forever. Defaults to null.

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

Support us

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License

The MIT License (MIT). Please see License File for more information.

spatie/laravel-partialcache 适用场景与选型建议

spatie/laravel-partialcache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 234.14k 次下载、GitHub Stars 达 203, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 spatie/laravel-partialcache 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 203
  • Watchers: 10
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04