How better to clear cache in redis for posts which are not updated very often ?
On laravel 10 site I have several types of data which I want to save in redis.
Different data have different time when data are expired.
I think I can do it in 2 ways :
// Store a value in the Redis cache with minutes set :
OR using Cache::foreve method with manuall clearing cache data of the app running scheduled tasks(if I need to refresh all cache)
or say if post is updated in admin panel to clear 'Post_Key' - so next calling it would be refreshed...
In .env file I have to keep
CACHE_DRIVER=redis
to use redis
I wonder which way (or some other) is preferable from the point of performance and stable work of the app ?
Month vs. forever is not going to make any difference from a performance point of view. Just make sure you invalidate the cache entry whenever a post is updated.
If you want to speed up Redis, install and use the PhpRedis extension instead of the Predis package. PhpRedis is written in C and is many times faster than Predis. But honestly, you probably won't notice a difference unless you're hitting the cache a lot.