lundi 28 août 2017

Laravel 5.4 - Cache an array

I am trying to cache an array, but for some reason, nothing is added. This is the code:

public static function getEmployees()
    {

        if(!Cache::has('employees')):

            $data      = ['urlPath' => '/employees/directory'];

            $params    = ['fields' => 'jobTitle'];

            $employees = API::callAPI('GET', $data, $params);

            Cache::putMany($employees, 1440);

        endif;

        return Cache::get('employees');

    }

And whey I try to get cached value (array), I am getting null:

dd(Cache::get('employees'));

And this is an array I want to store:

array:2 [▼
  "fields" => array:16 [▶]
  "employees" => array:257 [▶]
]

(I am using db for storing)



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vl5mP0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire