fleacache.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. use think\facade\Cache;
  3. final class fleacache {
  4. public static function getCache($type, $param = "") {
  5. $type = strtoupper($type[0]) . strtolower(substr($type, 1));
  6. $function = "get" . $type . "Cache";
  7. try {
  8. do {
  9. if (method_exists(fleacache, $function)) {
  10. break;
  11. } else {
  12. $error = lang('please_check_your_cache_type');
  13. throw new Exception($error);
  14. }
  15. } while (0);
  16. }
  17. catch(Exception $e) {
  18. }
  19. $result = self::$function($param);
  20. return $result;
  21. }
  22. private static function getFlea_areaCache($param) {
  23. $deep = $param['deep'];
  24. if (Cache::has("flea_area_" . $deep) && empty($param['new'])) {
  25. eval(Cache::get("flea_area_" . $deep));
  26. return $data;
  27. }
  28. $condition = array();
  29. $condition[] = array('fleaarea_deep','=',$deep);
  30. $order = "fleaarea_sort asc";
  31. $result = model('fleaarea')->getFleaareaList($condition,'*',$order);
  32. $tmp= "";
  33. $tmp.= "\$data = array(\r\n";
  34. if (is_array($result)) {
  35. foreach ($result as $k => $v) {
  36. $tmp.= "\tarray(\r\n";
  37. $tmp.= "\t\t'fleaarea_id'=>'" . $v['fleaarea_id'] . "',\r\n";
  38. $tmp.= "\t\t'fleaarea_name'=>'" . htmlspecialchars($v['fleaarea_name']) . "',\r\n";
  39. $tmp.= "\t\t'fleaarea_parent_id'=>'" . $v['fleaarea_parent_id'] . "',\r\n";
  40. $tmp.= "\t\t'fleaarea_sort'=>'" . $v['fleaarea_sort'] . "',\r\n";
  41. $tmp.= "\t\t'fleaarea_deep'=>'" . $v['fleaarea_deep'] . "',\r\n";
  42. $tmp.= "\t),\r\n";
  43. }
  44. }
  45. $tmp.= ");";
  46. try {
  47. if (Cache::set("flea_area_" . $deep,$tmp,3600) === FALSE) {
  48. $error = lang('please_check_your_system_chmod_area');
  49. throw new Exception();
  50. }
  51. eval(Cache::get("flea_area_" . $deep));
  52. return $data;
  53. }
  54. catch(Exception $e) {
  55. }
  56. }
  57. }
  58. ?>