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

Support more cache drivers or allow users to create their own #89

Open
benrowe-chuffed opened this issue Jun 21, 2023 · 2 comments
Open
Assignees
Labels

Comments

@benrowe-chuffed
Copy link

At the moment the setCache() only takes a handful of hard coded drivers (filesystem + some popular relational databases). It would be nice to write our own custom driver so we could implement a key/value store or another mechanism like s3.

@roberto-butti
Copy link
Collaborator

Exactly, i agree, at the moment is feasible only with PDO adapter and Filesystem adapter.
This is one of the most candidate features for the next major version, following PSR6/PSR16 and dependency injection.

@roberto-butti roberto-butti self-assigned this Jun 21, 2023
@silasjoisten
Copy link
Collaborator

To be honest, I believe it’s not the responsibility of the API client library to provide built-in caching options. This should be left to the user of the library. There are various caching mechanisms—such as key-value stores, file systems, or cloud storage like S3—and the user should be free to choose the one that best fits their needs.

From a design perspective, this aligns with the Single Responsibility Principle (SRP). The primary role of an API client is to interact with the API, not to manage caching. By trying to implement caching within the client, we would be coupling two distinct concerns—API communication and caching—making the library more complex and less flexible.

Users who need caching can implement it themselves, perhaps by using standardized interfaces like PSR-6 or PSR-16, which are designed specifically for caching in PHP applications. This keeps the library clean and focused on what it should be doing: facilitating API interaction, while giving the user full control over how they manage their caching strategy.

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

No branches or pull requests

3 participants