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 for cache force update #452

Open
Tamas-hi opened this issue Aug 30, 2024 · 0 comments
Open

Support for cache force update #452

Tamas-hi opened this issue Aug 30, 2024 · 0 comments

Comments

@Tamas-hi
Copy link

Tamas-hi commented Aug 30, 2024

Hello everyone!

I have been experimenting with this library, and had really positive expierences the past few days.

The application I am working with has to fetch a lot of data from an API, where a request takes about 1 minute to complete. To enhance user experience, I introduced caching. On that specific request, a one day cache expiry is totally acceptable, so I set it up:

public function cacheExpiryInSeconds(): int
{
    return 86400; // One day
}

However, since the request takes so long, I would like to introduce an hourly automatic cache update in the background using Laravel Scheduler. Here I would like to reuse the connector and the request that I have already defined:

Schedule::call(function () {
    $connector= new XYZConnector();
    $request = new TestRequest();
    $response = $connector->send($request);
})->hourlyAt('15');

Here comes my problem. This hourly job update will not update the cache because of the cacheExpiryInSeconds defined in the Request. However, I can't change that, because I want my users who are doing the request from the frontend to be able to used the cache version of the response for one day. :)

Should I change my approach here? Or is a 'cache force update' something that can be a great feature? With that, I would be able to forcefully overwrite the cache in my hourly job. Right now I don't see any other option just to stick to Laravel's manual Cache store.

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

No branches or pull requests

1 participant