sinemacula/laravel-cached-crypt 问题修复 & 功能扩展

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

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

sinemacula/laravel-cached-crypt

最新稳定版本:v1.0.0

Composer 安装命令:

composer require sinemacula/laravel-cached-crypt

包简介

A Laravel package that adds transparent caching to decrypted values for improved performance across encrypted attributes.

README 文档

README

Latest Stable Version Build Status StyleCI Maintainability Code Coverage Total Downloads

⚠️ Security Warning
This package caches decrypted values using Laravel's configured cache driver. You should only use this package with a cache store that provides encryption at rest, such as Redis or Memcached in a secured environment. Do not use this with insecure cache drivers like file or array, as decrypted data will be stored in plaintext on disk or in memory.

Laravel Cached Crypt is a zero-configuration package that transparently adds caching to Laravel’s Crypt facade, reducing CPU load by avoiding repeated decryption of encrypted values across your application.

Features

  • Transparent Integration: Automatically replaces Laravel's default Crypt implementation—no configuration or code changes required.
  • Cached Decryption: Caches decrypted values using Laravel's default cache driver (e.g. Redis) to improve performance on read-heavy encrypted fields.
  • Deployment-Friendly: Works seamlessly with deploy-based cache flushing strategies to keep cache fresh and consistent.

Installation

To install Laravel Cached Crypt, run the following command in your project directory:

composer require sinemacula/laravel-cached-crypt

Laravel will automatically register the service provider via package discovery.

Configuration

This package requires no configuration. Once installed, it will automatically override Laravel’s default Crypt binding and begin caching decrypted values across your application.

How It Works

Laravel Cached Crypt intercepts calls to Crypt::decryptString() and caches the decrypted output using a hash of the encrypted payload. On subsequent calls, it retrieves the decrypted value from cache rather than reprocessing the decryption.

This approach is especially effective for:

  • APIs that return encrypted model attributes in large datasets
  • Applications with frequent reads from encrypted fields
  • Reducing CPU load and PHP-FPM worker saturation under high concurrency

Security Considerations

Decrypted values are stored in your application’s configured cache store. Ensure that your cache backend (e.g. Redis) is properly secured, resides within a private network or VPC, and uses encryption in transit. This package does not alter Laravel’s encryption algorithms or key handling in any way.

Contributing

Contributions are welcome and will be fully credited. We accept contributions via pull requests on GitHub.

Security

If you discover any security-related issues, please email instead of using the issue tracker.

License

Laravel Cached Crypt is open-sourced software licensed under the Apache License, Version 2.0.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2025-05-25