定制 atldays/laravel-eloquent-query-cache 二次开发

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

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

atldays/laravel-eloquent-query-cache

Composer 安装命令:

composer require atldays/laravel-eloquent-query-cache

包简介

Adding cache on your Laravel Eloquent queries' results is now a breeze.

README 文档

README

Latest Version on Packagist Total Downloads CI License: Apache-2.0

atldays/laravel-eloquent-query-cache is a maintained fork of the original rennokki/laravel-eloquent-query-cache package.

If you only need the core package behavior, use the original documentation above. This fork keeps the original package experience and adds a few improvements for modern Laravel applications and additional relationship caching scenarios.

Installation

composer require atldays/laravel-eloquent-query-cache

Use the trait on models where query caching should be available:

use Atldays\QueryCache\Traits\QueryCacheable;

class Post extends Model
{
    use QueryCacheable;
}

What This Fork Adds

MorphTo caching support

The original package documentation covers the general caching API. This fork additionally supports cached morphTo relations with inherited cache configuration.

$commentable = $comment->commentable()
    ->cacheFor(now()->addHour())
    ->cacheTags(['commentable'])
    ->cachePrefix('comments')
    ->withPlainKey()
    ->first();

This is useful when you want polymorphic relations to behave the same way as the rest of your cached query chains.

Cache configuration inheritance for relationships

Custom cache options can now flow more consistently into supported relationship queries.

Typical examples:

  • cacheFor(...)
  • cacheTags([...])
  • cachePrefix(...)
  • withPlainKey()
  • cacheDriver(...)

Custom cache repository support

In addition to passing a driver name, you can pass a cache repository instance to cacheDriver():

use Illuminate\Support\Facades\Cache;

$posts = Post::query()
    ->cacheFor(300)
    ->cacheDriver(Cache::store('array'))
    ->get();

This is helpful when integrating the package into more customized application setups or when testing specific cache stores.

Using The Core API

The core query cache API remains aligned with the original package documentation. For the full feature set and the original behavior reference, see:

Common examples:

$posts = Post::cacheFor(3600)->get();

$post = Post::cacheFor(now()->addHour())->first();

$uncached = Post::dontCache()->get();

$tagged = Post::cacheFor(600)->cacheTags(['posts'])->get();

Testing

vendor/bin/pint --test
vendor/bin/phpunit

If you run the project through Docker, the commands used in this repository are:

docker run --rm -u $(id -u):$(id -g) -v "$PWD:/app" -w /app composer:2 sh -lc 'vendor/bin/pint --test'
docker run --rm -u $(id -u):$(id -g) -v "$PWD:/app" -w /app composer:2 sh -lc 'composer test'

Contributing

Please see CONTRIBUTING for details.

Security

If you discover a security issue, please open a private report with the repository maintainers instead of posting sensitive details publicly.

atldays/laravel-eloquent-query-cache 适用场景与选型建议

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

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

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

围绕 atldays/laravel-eloquent-query-cache 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-04-11