Skip to content
This repository was archived by the owner on Apr 4, 2022. It is now read-only.

CachingΒ #1

@driesvints

Description

@driesvints

Performing GraphQL calls can be costly and take quite a bit of time. Ideally I'd like to have dedicated caching support in the library. Most calls to check for sponsorships of GitHub users or to retrieve a list of sponsors don't need to be checked every second.

The way I see it we can ship a decorator for the GitHubSponsors client. This would look like as follows:

final class CachedGitHubSponsors
{
    public function __construct(
        private GitHubSponsors $client
    ) {}
    
    public function isSponsoredBy(string $account, string $sponsor, bool $isAccountAnOrganization = false): bool
    {
        // check cached status

        return $this->client->isSponsoredBy($account, $sponsor, $isAccountAnOrganization);
    }

    // ...
}

Maybe a common interface is needed?

I think this class should require a Psr\SimpleCache\CacheInterface implementation to handle the caching. For Laravel it can be retrieved from the already set cache store. We can add options to the github-sponsors.php config file to set the specific cache store and timeouts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions