Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml,json,xml}]
indent_size = 2
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve SmartCache
title: '[BUG] '
labels: bug
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Cache Driver used: (e.g. Redis, File, Memcached)
2. Value being cached: (e.g. array, collection, model, string)
3. Code snippet:
```php
// Your caching code here
```
4. The error or unexpected behavior encountered.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment details:**
- PHP Version: [e.g. 8.1]
- Laravel Version: [e.g. 10.x]
- SmartCache Version: [e.g. 1.0.0]
- Cache Driver used: [e.g. Redis]

**Additional context**
Add any other context about the problem here (e.g. is `ext-zlib` installed? Are you using adaptive compression?).
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Feature request
about: Suggest an idea for this project
title: '[FEATURE] '
labels: enhancement
assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
2 changes: 1 addition & 1 deletion .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, zlib
coverage: xdebug

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, zlib
coverage: none

- name: Setup problem matchers
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor/
composer.lock
.phpunit.cache/
coverage/
.DS_Store
Expand Down
160 changes: 160 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Changelog

All notable changes to the `iazaran/smart-cache` package will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.9.3] - 2026-04-14
### Added
- Added `SECURITY.md` for standardized enterprise vulnerability disclosures.
- Added `CHANGELOG.md` following the Keep a Changelog standard.
- Added `.editorconfig` to enforce formatting consistency across contributors.
- Issue and Pull Request GitHub templates added to standardize bug tracking.
### Changed
- Enriched `config/smart-cache.php` inline documentation for advanced strategies like `adaptive mode` and `circuit_breaker`.
- Appended `ext-zlib` and `ext-json` extension suggestions to `composer.json`.
- Enhanced `CONTRIBUTING.md` with test commands, PSR-12 standards, and security disclosure references.
- Added `zlib` extension to CI workflows for explicit compression test coverage.
- Updated documentation and `README.md` with deep-dive troubleshooting and "Best Practices" examples.
- Added `composer.lock` to `.gitignore` (library best practice).
### Fixed
- Fixed dashboard route documentation (`/stats` → `/statistics`) in README and `docs/index.html`.

## [1.9.2] - 2026-03-17
### Added
- Feature: Added official support for Laravel 13 framework requirements.
- Implemented `touch()` method functionality and boot-safe event registration to comply with Laravel 13 architectures.
### Fixed
- Fixed tests for Symfony Console compatibility allowing both `add()` and `addCommand()`.

## [1.9.1] - 2026-03-04
### Changed
- Improved current features functionality.
- Enhanced and updated the `README.md` and documentation files for a better Developer Experience (DX).

## [1.9.0] - 2026-02-20
### Added
- Added Write Deduplication (Cache DNA) optimization to save unnecessary I/O writes.
- Self-Healing Cache feature and Conditional Caching functionality implemented.
- Significant SEO improvements in `composer.json` and meta-tags.
### Fixed
- Addressed assorted bug fixes reported by the community.

## [1.8.0] - 2026-02-08
### Added
- Introduced Cost-Aware caching to prioritize memory eviction efficiently.
- Various under-the-hood fixes and optimization refinements.

## [1.7.0] - 2026-01-19
### Added
- Feature Request #31: Implemented `store()` method support directly on the SmartCache facade.

## [1.6.0] - 2025-12-06
### Added
- General core improvements and new minor features for package robustness.

## [1.5.0] - 2025-10-19
### Added
- New core features and expanded cache optimization solutions for large objects.

## [1.4.3] - 2025-09-27
### Changed
- Extended documentation coverage in `docs/index.html` and `README.md`.

## [1.4.2] - 2025-09-26
### Changed
- Improved the internal mechanism for managing keys for mass invalidation dynamically.

## [1.4.1] - 2025-09-26
### Changed
- Optimization applied to the `flexible` macro implementation.

## [1.4.0] - 2025-09-26
### Added
- Comprehensive dependency tracking mechanism.
- Full Cache Tag support implementations.
- Powerful cache invalidation strategies and helpers.

## [1.3.7] - 2025-09-25
### Added
- Robust test coverage established ensuring compatibility with PHP 8.1+ and Laravel 8+.

## [1.3.6] - 2025-09-08
### Fixed
- Bugfix: Resolves Issue #18 where cache `flexible` logic was not operating as expected under certain payloads.

## [1.3.5] - 2025-09-02
### Fixed
- Resolved PHP parameter type warnings related to strict nullable types.

## [1.3.4] - 2025-09-02
### Fixed
- Bugfix: Issue #14 regarding keys stored but not registering properly on status checks.

## [1.3.3] - 2025-09-01
### Fixed
- Bugfix: Addressed Issue #12 covering data cleared by a specifically defined key.

## [1.3.2] - 2025-08-31
### Fixed
- Continued stabilization for manual key data clearance mechanics (Issue #12).

## [1.3.1] - 2025-08-31
### Fixed
- Bugfix: Resolved Issue #8 concerning multiple conflicting strategies applying to single cache allocations.

## [1.3.0] - 2025-08-31
### Added
- Feature Request #7: Implemented dedicated support for cache `flexible` macros.

## [1.2.2] - 2025-08-30
### Added
- Deployed structured unit testing cases asserting early system stability.

## [1.2.1] - 2025-06-03
### Added
- Added Google site verification file for better SEO visibility compliance.

## [1.2.0] - 2025-06-03
### Changed
- Various repository refinements tailored towards improving SEO and discoverability.

## [1.1.0] - 2025-04-22
### Added
- Introduced the `smart_cache` global helper function to provide a drop-in analogue for Laravel's `cache` helper.

## [1.0.1] - 2025-04-21
### Changed
- Package-wide code refactoring, structural cleanup, and PSR standard reformatting.

## [1.0.0] - 2025-04-21
### Added
- Initial package scaffolding and base logic commit.

[1.9.3]: https://github.com/iazaran/smart-cache/compare/1.9.2...1.9.3
[1.9.2]: https://github.com/iazaran/smart-cache/compare/1.9.1...1.9.2
[1.9.1]: https://github.com/iazaran/smart-cache/compare/1.9.0...1.9.1
[1.9.0]: https://github.com/iazaran/smart-cache/compare/1.8.0...1.9.0
[1.8.0]: https://github.com/iazaran/smart-cache/compare/1.7.0...1.8.0
[1.7.0]: https://github.com/iazaran/smart-cache/compare/1.6.0...1.7.0
[1.6.0]: https://github.com/iazaran/smart-cache/compare/1.5.0...1.6.0
[1.5.0]: https://github.com/iazaran/smart-cache/compare/1.4.3...1.5.0
[1.4.3]: https://github.com/iazaran/smart-cache/compare/1.4.2...1.4.3
[1.4.2]: https://github.com/iazaran/smart-cache/compare/1.4.1...1.4.2
[1.4.1]: https://github.com/iazaran/smart-cache/compare/1.4.0...1.4.1
[1.4.0]: https://github.com/iazaran/smart-cache/compare/1.3.7...1.4.0
[1.3.7]: https://github.com/iazaran/smart-cache/compare/1.3.6...1.3.7
[1.3.6]: https://github.com/iazaran/smart-cache/compare/1.3.5...1.3.6
[1.3.5]: https://github.com/iazaran/smart-cache/compare/1.3.4...1.3.5
[1.3.4]: https://github.com/iazaran/smart-cache/compare/1.3.3...1.3.4
[1.3.3]: https://github.com/iazaran/smart-cache/compare/1.3.2...1.3.3
[1.3.2]: https://github.com/iazaran/smart-cache/compare/1.3.1...1.3.2
[1.3.1]: https://github.com/iazaran/smart-cache/compare/1.3.0...1.3.1
[1.3.0]: https://github.com/iazaran/smart-cache/compare/1.2.2...1.3.0
[1.2.2]: https://github.com/iazaran/smart-cache/compare/1.2.1...1.2.2
[1.2.1]: https://github.com/iazaran/smart-cache/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/iazaran/smart-cache/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/iazaran/smart-cache/compare/1.0.1...1.1.0
[1.0.1]: https://github.com/iazaran/smart-cache/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/iazaran/smart-cache/releases/tag/1.0.0
36 changes: 34 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Contributing

I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
Expand All @@ -7,17 +8,48 @@ I love your input! I want to make contributing to this project as easy and trans
- Proposing new features
- Becoming a maintainer

## Security Vulnerabilities

If you discover a security vulnerability, please review our [Security Policy](SECURITY.md) for responsible disclosure instructions. **Do not** open a public GitHub issue for security concerns.

## All Code Changes Happen Through Pull Requests

Pull requests are the best way to propose changes to the codebase. I actively welcome your pull requests:

1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs or functions, update the documentation.
4. Make sure your code lints.
5. Issue that pull request!
4. Ensure your code follows the **PSR-12** coding standard.
5. Make sure your code lints and all tests pass.
6. Document notable changes in your PR description for the [CHANGELOG](CHANGELOG.md).
7. Issue that pull request!

## Running Tests

```bash
# Run the full test suite
composer test

# Run with code coverage
composer test-coverage
```

All pull requests must pass the existing test suite (425+ tests) before merging. If you add a new feature, include corresponding test cases.

## Coding Style

This project follows the **PSR-12** coding standard. Key points:

- Use 4 spaces for indentation (enforced by `.editorconfig`)
- Opening braces on the same line for control structures
- Opening braces on the next line for classes and methods
- One `use` declaration per line
- Type declarations and return types where applicable

## Any contributions you make will be under the MIT Software License

In short, when you submit code changes, your submissions are understood to be under the same.

## License

By contributing, you agree that your contributions will be licensed under its MIT License.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ Implements `Illuminate\Contracts\Cache\Repository` and PSR-16 `SimpleCache`. You

## Installation

**Prerequisites:** PHP extensions `ext-zlib` (for data compression) and `ext-json` (for optimal object serialization) are strongly recommended to enable all performance optimization strategies.

```bash
composer require iazaran/smart-cache
```

That's it. No configuration required — works immediately with your existing cache driver.
That's it. No further configuration is required — works immediately with your existing cache driver.

## Quick Start

Expand Down Expand Up @@ -264,7 +266,7 @@ SmartCache::analyzePerformance(); // health score + recommendations
```php
// Enable web dashboard
'dashboard' => ['enabled' => true, 'prefix' => 'smart-cache', 'middleware' => ['web', 'auth']],
// GET /smart-cache/dashboard | /smart-cache/stats | /smart-cache/health
// GET /smart-cache/dashboard | /smart-cache/statistics | /smart-cache/health
```

```bash
Expand All @@ -274,6 +276,13 @@ php artisan smart-cache:warm --warmer=products --warmer=categories
php artisan smart-cache:cleanup-chunks
```

## Best Practices & Troubleshooting

- **Binary Data:** If caching already compressed objects like images, video, or encrypted data, disable `compression` for those specific cache keys as they waste CPU cycles without yielding size reductions.
- **Memory Limits with Chunking:** Large multi-megabyte datasets automatically trigger the 'chunking' strategy. For arrays over 100,000 items, verify `memory_limit` in `php.ini` or enable `lazy_loading` via config to avoid server crashes.
- **Provider Not Found:** Laravel aggressively caches service providers and aliases. Always run `php artisan optimize:clear` after upgrading or installing this package if encountering *"Class 'SmartCache' not found"*.
- **IDE Autocomplete:** Modern IDEs (PhpStorm, VSCode) completely resolve `SmartCache::` magical methods automatically via our included Facade PHPDocs without needing `ide-helper` generated files.

## Configuration

Publish the config file (optional — sensible defaults are applied automatically):
Expand Down
23 changes: 23 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Security Policy

## Supported Versions

Currently, the following versions are actively receiving security updates. We always recommend upgrading to the latest minor version (`^1.9.0`) with your Laravel installation to ensure optimal performance, structural compliance, and security.

| Version | Maintained? | PHP Requirements | Laravel Framework |
| ------- | ------------------ | ---------------- | ----------------- |
| >= 1.9.0| :white_check_mark: | PHP 8.1+ | 8.x – 13.x |
| >= 1.3.7| :warning: | PHP 8.1+ | 8.x – 12.x |
| < 1.3.7 | :x: | - | - |

## Reporting a Vulnerability

If you discover a security vulnerability within the **SmartCache** package, please send an e-mail to **Ismael Azaran** at **eazaran@gmail.com**. We assess all incoming reports within 48 hours to determine the scope and risk of the disclosure.

Please **do not** publicly disclose the issue on GitHub until we have had an opportunity to address it and publish a fix. When reporting a defect, please include:

- The Cache Driver and Database you are using (e.g. Redis, File, Memcached, MySQL)
- Whether the issue pertains to data leakage, cache poisoning, deserialization exploits, or denial of service
- Precise steps to reproduce the issue locally

Once verified, we will work closely with you on a patch and coordinate a security advisory release on GitHub to ensure all developers using the package can update seamlessly and safely.
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
"mockery/mockery": "^1.5",
"symfony/var-dumper": "^5.4|^6.0|^7.0|^8.0"
},
"suggest": {
"ext-zlib": "Required for compressing cached data using gzip (strongly recommended)",
"ext-json": "Required for optimal auto-serialization of complex arrays",
"ext-redis": "Recommended when utilizing the Redis cache driver for better performance",
"ext-memcached": "Recommended when using the Memcached cache driver for distributed caching"
},
"autoload": {
"psr-4": {
"SmartCache\\": "src/"
Expand Down
Loading
Loading