ShopCategoryLogic.php 820 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\admin\logic;
  3. use app\admin\model\dao\ShopCategory;
  4. use app\admin\model\dao\ShopGoodsSpec;
  5. use app\admin\model\dao\ShopGoodsSpecRelation;
  6. use app\admin\model\dao\ShopGoodsSpecType;
  7. use app\admin\model\dao\ShopGoodsType;
  8. use app\common\model\ShopGoods;
  9. use think\facade\Cache;
  10. use think\facade\Db;
  11. class ShopCategoryLogic
  12. {
  13. private static $CACHE_ID_KEY = "cache:shop_category:id:";
  14. public static function getCateById($id)
  15. {
  16. $key = self::$CACHE_ID_KEY . $id;
  17. if (Cache::has($key)) {
  18. return Cache::get($key);
  19. }
  20. $name = ShopCategory::getById($id);
  21. Cache::set($key, $name, 10 * 60);
  22. return $name;
  23. }
  24. public static function delIdCache($id)
  25. {
  26. $key = self::$CACHE_ID_KEY.$id;
  27. Cache::delete($key);
  28. }
  29. }