Using Laravel's cache

0

I would like to know if the way I'm working with cache is correct and if there is anything more practical for it.

Follow the code:

<?php
namespace App\Modules\Admin\Controllers;

use Cache;
use Auth;

class Network extends Controller
{
    public function teste()
    {
        if( ! Cache::has('user') ) {
            $user = Auth::user();
            Cache::store('file')->put('user', $user, 10);
        } else {
            $user = Cache::get('user');
        }

        return view('cms::user', [
            'user' => $user
        ]);
    }
}

Thank you for understanding.

    
asked by anonymous 18.09.2016 / 05:28

0 answers