$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);
海绵宝宝撒