Category : caching

I have a schedule task which runs every 5 minutes. This schedule command puts some data to Redis cache via controller. Kernel.php … protected $commands = [ CommandsDataCommand::class, ]; protected function schedule(Schedule $schedule) { $schedule->command(‘data:cache’)->everyFiveMinutes()->onOneServer()->runInBackground(); } DataCommand.php … public function handle() { app(‘AppHttpControllersDataProcessing’)->setCache(); } DataProcessing.php … public function setCache() { $data = [‘one’, ‘two’, ‘three’]; ..

Read more

I’m trying to remember cache for 6 minute on home page but it’s errors. I want 10 parameters in one key ( homepage-data ) so what i’m doing wrong? public function index() { $rememberKey = ‘homepage-data’; $minutes = 600; Cache::remember($rememberKey, $minutes, function () { $breakingNews = BreakingNews::published(); $rightSlider = Article::rightSlider()->take(20)->get(); $leftSlider = Article::leftSlider()->take(9)->get(); $shows = ..

Read more

We are serving multiple tenants with a laravel application, switching between tenants with: config([‘cache.prefix’ => $cachePrefix]); Cache::setPrefix($cachePrefix); Then sometimes when we call: Cache::tags(‘TagName’)->add($model->getTable(), 1, $this->refreshTime); We get this stack trace: ErrorException unserialize(): Error at offset 0 of 2 bytes /usr/share/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php:345 IlluminateFoundationBootstrapHandleExceptions::handleError [internal] unserialize /usr/share/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php:345 IlluminateCacheRedisStore::unserialize /usr/share/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php:64 IlluminateCacheRedisStore::get /usr/share/vendor/laravel/framework/src/Illuminate/Cache/TagSet.php:87 IlluminateCacheTagSet::tagId [internal] array_map /usr/share/vendor/laravel/framework/src/Illuminate/Cache/TagSet.php:76 IlluminateCacheTagSet::tagIds /usr/share/vendor/laravel/framework/src/Illuminate/Cache/TagSet.php:66 IlluminateCacheTagSet::getNamespace ..

Read more

Laravel Version: 8..4 PHP Version: 7.4.3 Database Driver & Version: mysql Ver 8.0.26-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu)) Description: I have a live laravel website running on aws ebs. I entered the admin panel with laravel voyager to run some php artisan commands with laravel voyager compass. I first ran ‘php artisan view:cache’ and it ..

Read more

I am trying to optimize a project that is working pretty slow using caching. I’m facing a problem that I don’t quite understand how to cache full eloquent models with their relationships and later on covert them back to a model with all relations intact. Here’s a fragment of my code if (Cache::has($website->id.’_main_page’)) { $properties ..

Read more

We’re using Laravel (8) rate limiter and running into constant duplicate key violations in our cache table. Postgres is throwing fits because of the constant attempts to write to the cache with the same key. We’re getting duplicate key value violates unique constraint "cache_key_unique" errors, and it looks like every time (and with everyone) it’s ..

Read more