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

feat: add carbon support for cache expiry #10

Closed
wants to merge 2 commits into from
Closed

feat: add carbon support for cache expiry #10

wants to merge 2 commits into from

Conversation

innocenzi
Copy link

@innocenzi innocenzi commented Mar 30, 2023

This pull request adds nesbot/carbon support for determining the cache TTL.

I'm used to use now()->addHour() for the TTL on Laravel's caching utilities, so it was a bummer when migrating some code to Saloon to see it doesn't support this.

To achieve support for this feature without breaking change, the Cacheable interface has been changed to remove cacheExpiryInSeconds. Instead, the HasCaching trait uses method_exists to find either the deprecated cacheExpiryInSeconds or the new cacheExpiry method.

The new cacheExpiry can either return an int or a CarbonInterface. In either case, the cache expiry will be resolved to seconds internally to minimize changes to the codebase.


Note that I have other concerns with the DX, as stated in https://github.com/Sammyjo20/saloon-cache-plugin/issues/11, so maybe it's worth not accepting this PR and make a bigger refactor for a better Laravel integration

@innocenzi innocenzi closed this by deleting the head repository Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant