laravel-5eloquentcashapelayerlaravel-cashiercache-expiration

how can i set new cashe just in 10s using laravel Cashe


I used put function for make new manual Cashe. for example :

$cashtime =Cache::put('filekey', 'mycashtime', 20);

and sent it to view but it not expired . when i send it to view it will back me true. but after 20s have to send me false and expire it.

and then how can i check it is expired or not .


Solution

  • I solved it.my problem was first I have to check if key doesnt exist set again else do someting.

           view()->composer('admin.sidebar', function($view){
                $cashtime = Cache::get('filekeys');
                if($cashtime == Null){
                        Cache::put('filekeys', 'mycashtimes', now()->addMinutes(1));
                        //do something
                }else{
                    //do something
                }
                
                $view->with(['testmneda' => $cashtime]);
            });