$this->getCachedCategories();
//Above code Stores the data in cache for future use. So, it goes to the database only
//one time and next time pick the data from cache. So far everything is good.
//I have a search criteria which is in the form of array. I filter above cache data based
//upon the search criteria and gets the data.
foreach ($userInputsForFilter as $key => $value) {
$this->Categories = $this->Categories->where($key, $value);
}
Вот скриншот. Если вы заметили, что полученные данные имеют первый индекс с 1 вместо 0. На самом деле вторая запись появилась после того, как данные кэша были отфильтрованы.

Подскажите, пожалуйста, почему это происходит при поиске данных в кеше? Это не происходит при переходе в базу данных.
Массив в код JSON
$CategoryResponse = $this->iCategory->All([], []);
return \Response::json($CategoryResponse, 200);