Support the ongoing development of Laravel.io →
Cache Database Architecture

I have built a business application using Laravel that utilizes several very large datasets. There is a significant amount of processing and calculation that must be performed to prepare some aggregate data for display. Obviously, we are using Cache to prevent the user from having to wait for the pre-processing to occur, when possible. In some cases, it can take more than 30 seconds to crunch all the data and prepare the page for display. The datasets are refreshed by services that run every 4 or 24 hours depending on the dataset and so it is necessary to expire the cache to make sure that the data on the application does not get too stale. This means that about every 4 hours, some unlucky user is going to have to have an extremely long page load time.

I am looking for ideas that folks might have about how to re-structure the application in such a way so that, when a service runs to update a dataset in our database, a process/job/queue would run for the application and would update any affected cached objects. The idea is that we could set the cache to never expire and then force cache updates related to the data being refreshed rather than the user triggering its expiration and re-generation.

Any ideas, code, or psuedo-code are appreciated!

Last updated 3 years ago.
0

Hi,

I would do the "processing and calculation" by running a command every 4 hours and this should be called by a cron. That data is saved in a cache preferable to be Redis where is going to be read by the your application.

You can set the Redis expire to a certain time and if that passes you can leave the process to be done as it is done now just as a fallback .

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

pyrello pyrello Joined 21 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.