aprivette/laravel-cache-refs 问题修复 & 功能扩展

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

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

aprivette/laravel-cache-refs

最新稳定版本:1.0.1

Composer 安装命令:

composer require aprivette/laravel-cache-refs

包简介

A Laravel Artisan command to purge cache tag refs from Redis

README 文档

README

A Laravel Artisan command to purge cache tag refs from Redis.

Problem

Have you noticed massive Redis sets which have the key suffix standard_ref or forever_ref clogging up your cache database?

If you use Laravel's cache tag feature and are unable to routinely wipe your entire cache, you will inevitably accumulate junk in your Redis database. To make this feature work, Laravel creates Redis sets for each tag with members pointing to each key assigned to that tag.

For example, let's say you have a cache key "dog" with the tag "animal". If the "dog" Redis key expires, that key's set member remains for the "animal" tag.

Solution

This command is designed to be run on a schedule job for applications experiencing this issue. It loops through all cache refs and ensures the ref set members point to existing keys. It will remove any set members that point to non existant target keys.

Usage

Install:

composer require aprivette/laravel-cache-refs

After installing, you can run the command like so:

php artisan refs:purge

This command defaults to the cache connection. If you have another cache connection, you may specify it.

php artisan refs:purge custom_redis_connection

Caveats

This package only works with Redis stores.

Future Improvements

The key queries should probably be replaced with scans for memory conservation with larger Redis stores. I haven't run into this issue yet though.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-09