示例#1
0
 public function getCategoryList()
 {
     $data = get();
     $default = array('page' => 0, 'clear_cache' => 0);
     extract(array_merge($default, $data));
     $cache_id = 'dln_category';
     if (!empty($clear_cache)) {
         Cache::forget($cache_id);
     }
     $limit = DLN_LIMIT;
     $skip = (int) $page * $limit;
     if (!Cache::has($cache_id)) {
         $records = FbCategory::whereRaw('status = ?', array(true))->skip($skip)->take($limit)->get()->toArray();
         Cache::put($cache_id, json_encode($records), DLN_CACHE_LONG_MINUTE);
     } else {
         $records = json_decode(Cache::get($cache_id));
     }
     return Response::json(array('status' => 'success', 'data' => $records), 200);
 }