Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore: remove dependency on thecodingmachine/cache-utils #695

Merged
merged 3 commits into from
Jul 16, 2024

Conversation

xyng
Copy link
Contributor

@xyng xyng commented Jul 15, 2024

The package seems to be unmaintained and prevents usage due to old psr/simple-cache.
This removes the dependency on that package, which provided cache clearance on Classes and ParentClasses when their files changed.
The functionality can still be achieved by creating a custom implementation of TheCodingMachine\GraphQLite\Utils\Cache\ClassBoundCacheContractFactoryInterface that returns a wrapped version of thecodingmachine/cache-utils or an updated fork.

My implementation is quite naive and changes how the caching works. This may be considered a breaking change.

I'm happy to make adjustments if needed.

fixes #693

Note: PHPStan seems to have problems. This is probably not related to my changes.

@@ -28,6 +29,7 @@ public function __construct(
private readonly RecursiveTypeMapperInterface $recursiveTypeMapper,
private readonly ContainerInterface $container,
private readonly CacheInterface $cache,
private readonly ClassBoundCacheContractFactoryInterface|null $classBoundCacheContractFactory = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shoud it be added at the end of the list to preserve BC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good Catch! I added it near to cache for no particular reason (maybe optics?).
Will adjust later.

@oojacoboo
Copy link
Collaborator

oojacoboo commented Jul 16, 2024

@xyng thanks for this. For PHPStan, yea, not sure what's going on with that. It looks like a syntax recommended change. If you could give that a shot, that'd be great.

I think it'd be best to place this in src/Cache and not in the src/Utils/Cache directory. Utils directories are like junk drawers, the mere existence of them just encourages poor organization.

I think with @andrew-demb's recommendation on the __constructor ordering, there shouldn't be any BC issues.

@xyng
Copy link
Contributor Author

xyng commented Jul 16, 2024

@oojacoboo @andrew-demb i have adjusted according to your feedback. Thanks a lot!
I also added a setter setClassBoundCacheContractFactory to the SchemaFactory to actually allow users to customize.

Edit: I also found I've missed using the cachePrefix in the set in ClassBoundCacheContract and I had a complaint from PHPCS. Bot fixed in the following commit-updated.

@xyng xyng force-pushed the master branch 3 times, most recently from 85c3ca1 to 337b7f8 Compare July 16, 2024 06:47
xyng added 2 commits July 16, 2024 08:59
The package seems to be unmaintained and prevents usage due to old
psr/simple-cache. This removes the dependency on that package.
The package provided cache clearance on Classes and ParentClasses when their files changed.
This functionality can still be achieved by creating a custom implementation of
`TheCodingMachine\GraphQLite\Utils\Cache\ClassBoundCacheContractFactoryInterface`.

fixes thecodingmachine#693
@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.38%. Comparing base (53f9d49) to head (7050140).
Report is 87 commits behind head on master.

Files Patch % Lines
src/SchemaFactory.php 50.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #695      +/-   ##
============================================
- Coverage     95.72%   95.38%   -0.34%     
- Complexity     1773     1811      +38     
============================================
  Files           154      173      +19     
  Lines          4586     4791     +205     
============================================
+ Hits           4390     4570     +180     
- Misses          196      221      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…eprecation

This is necessary because symfony/cache is not compatible with every supported
version of psr/simple-cache.
More info here: symfony/symfony#44738
@oojacoboo oojacoboo merged commit 069d62a into thecodingmachine:master Jul 16, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update cache-utils library
4 participants