0

I have a laravel application gets a key from redis, and it it doesn't exist gets the data from the databse, puts that data in the cache, and then returns to the user.

I'd like to be able to return the data to the user first, then keep processing the cache server side, rather than waiting for the cache before returning.

Is there a name for this? How would I go about doing this on a standard laravel installation?

1 Answers1

0

This pointed me in the right direction

In Laravel, how can I add items to array in controller and then process after response via App::finish()

I needed to use App::finish

With a PHP closure, you can pass data using the "use" keyword.

Community
  • 1
  • 1
  • Note that with Laravel 5.0, `App::finish` does not exist. Not sure what would be considered equivalent. – Jake Z Feb 09 '15 at 22:45
  • It was officially released recently and all the documentation now defaults to the 5.0 version, so I assume it is production ready. – Jake Z Feb 10 '15 at 16:09
  • The Laravel 5 alternative is to use `TerminableMiddleware`. See http://stackoverflow.com/a/28340178/1532882. – Jake Z Feb 10 '15 at 16:24