S
S
shasoft2019-01-27 20:47:41
Laravel
shasoft, 2019-01-27 20:47:41

Is there a library for caching before the event occurs (Laravel)?

Laravel has a cache class that caches for a certain amount of time.
The idea is simple - cache before the event occurs. Those. caching does not occur for a certain time, but until a certain event occurs. I’m doing just that, but, perhaps, everything has already been invented before me and is actively used, and only I don’t know.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin B., 2019-01-27
@Kostik_1993

If you pass a timestamp instead of a time in minutes, the cache will live until this time

$expiresAt = now()->addMinutes(10);
Cache::put('key', 'value', $expiresAt);

P
PandaTheSlayer, 2019-01-28
@PandaTheSlayer

https://github.com/GeneaLabs/laravel-model-caching
There is such a library.

A
Alex Wells, 2019-01-28
@Alex_Wells

You do Cache::forever(), and when an event occurs, inside the handler - Cache::remove() (or delete, I don't remember). There is no prettier solution, and it is not particularly necessary - it is too specific a case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question