Skip to content

PHP Cache Engine v6.0 #17

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

PHP Cache Engine v6.0 #17

wants to merge 8 commits into from

Conversation

byjg
Copy link
Owner

@byjg byjg commented Mar 23, 2025

This pull request updates PHP Cache Engine with several significant improvements and some breaking changes. The library continues to provide PSR-6 and PSR-16 cache implementations with multiple storage drivers, now with enhanced PHP 8.1-8.4 compatibility and modernized code.

Major Changes

  • Added PHP 8.4 compatibility
  • Upgraded PHPUnit to support versions 10.5-11.5
  • Added support for Psalm 6.2
  • Added #[Override] attribute to methods implementing interfaces
  • Renamed createRedisCacheEngine() method to createRedisPool() for naming consistency
  • Improved handling of timestamp calculations in the addToNow() method
  • Enhanced return type handling in several methods
  • Restructured and modernized documentation
  • Added Gitpod configuration for easier development
  • Reorganized test class hierarchy

Breaking Changes

Component Change Impact
Factory Method createRedisCacheEngine() renamed to createRedisPool() Code using the old method name will break
Dependencies PHPUnit upgraded from 9.6 to 10.5/11.5 Tests written for PHPUnit 9.x may need updates
BaseCacheEngine Return type for withKeysFromContainer() changed to static Static analysis tools may identify this change
addToNow() Better handling of invalid timestamps May change behavior with invalid inputs
Documentation Restructured formatting and organization Documentation links may need updating

Other Improvements

  • Added strict type handling throughout the codebase
  • Enhanced documentation formatting and organization
  • Improved GitHub Actions workflow
  • Code refactoring for better readability and maintainability
  • Better test organization with consistent naming conventions

Compatibility

  • Requires PHP 8.1 or higher (supports up to PHP 8.4)
  • PSR-6, PSR-16, PSR-3, and PSR-11 compliant
  • Maintains backward functional compatibility except for the changes noted above

Upgrade Instructions

To upgrade from a previous version:

  1. Update references to createRedisCacheEngine() to use createRedisPool() instead
  2. If you're extending any core classes, ensure your implementations handle the return type changes
  3. Update your test suite if using PHPUnit to be compatible with newer versions (10.5+)
  4. Update your composer dependencies: composer require "byjg/cache-engine:^6.0"

Description by Korbit AI

What change is being made?

Enhance the PHP Cache Engine to version 6.0 by adding support for PHP 8.4, introducing new dependencies, updating test configurations, refining documentation, and improving code consistency with PHP 8.1+ features.

Why are these changes being made?

These changes address the need for compatibility with the latest PHP versions and enhance testing robustness by using environment variables for cache service configurations. The introduction of new testing features and refactored code aims to improve maintainability while ensuring adherence to PSR standards and supporting future updates with enhanced logging and container support features.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

byjg added 8 commits March 20, 2025 07:32
Include #[Override] attributes in methods for better code clarity and compliance, and update PHPUnit configurations and tests for PHP 8.4 support. Enhance documentation, streamline compatibility with newer versions of dependencies, and improve general code maintainability."
Add a `.gitpod.yml` setup for development environments and a VS Code debug configuration for PHP projects. Migrated PHPUnit annotations for data providers to PHP 8 attributes for improved code clarity and compliance with modern PHP versions.
Renamed `BaseCacheTest` to `TestBase` and updated corresponding test classes to align with the new naming convention. This improves readability and ensures consistent naming across the test suite.
Renamed test base classes for better clarity and cohesion, consolidating them under `MainTest`. Simplified imports by using concise class references, improving readability and maintainability. These changes enhance test structure organization and prepare the codebase for potential future extensions.
Renamed `MainTest` to `TestBase` and made it abstract to better reflect its role as a base class. Updated derived test classes (`CachePSR16MainTest` and `CachePSR6MainTest`) to extend `TestBase` and renamed them for consistency.
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Fix Detected
Documentation Undocumented default expiration ▹ view
Files scanned
File Path Reviewed
src/Factory.php
src/Psr6/CacheItem.php
src/Psr16/SessionCacheEngine.php
src/Psr16/NoCacheEngine.php
src/Psr16/BaseCacheEngine.php
src/Psr16/ArrayCacheEngine.php
src/Psr6/CachePool.php
src/Psr16/ShmopCacheEngine.php
src/Psr16/RedisCacheEngine.php
src/Psr16/MemcachedEngine.php
src/Psr16/FileSystemCacheEngine.php

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • On any given comment that Korbit raises on your pull request, you can have a discussion with Korbit by replying to the comment.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Current Korbit Configuration

General Settings
Setting Value
Review Schedule Automatic excluding drafts
Max Issue Count 10
Automatic PR Descriptions
Issue Categories
Category Enabled
Documentation
Logging
Error Handling
Readability
Design
Performance
Security
Functionality

Feedback and Support

Note

Korbit Pro is free for open source projects 🎉

Looking to add Korbit to your team? Get started with a free 2 week trial here

Comment on lines 99 to 101
public function expiresAfter(int|\DateInterval|null $time): static
{
$this->expiration = new DateTime('now +1 year');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undocumented default expiration category Documentation

Tell me more
What is the issue?

The default expiration of 1 year when null is passed is not documented, which is a significant behavior that affects cache item lifetime.

Why this matters

Missing documentation about default behaviors can lead to unexpected outcomes when using the cache system.

Suggested change ∙ Feature Preview

/**

  • Sets the expiration time for this cache item.
  • {@inheritdoc}
  • @param int|\DateInterval|null $time The expiration time
  • @return static
  • @note When null is passed, defaults to 1 year expiration
    */
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant