SupplierCache.Class.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * 供应商缓存
  4. * Created by PhpStorm.
  5. * User: haoren
  6. * Date: 2020/12/17
  7. * Time: 17:00
  8. */
  9. namespace JinDouYun\Cache;
  10. use Mall\Framework\Factory;
  11. use Mall\Framework\Core\ResultWrapper;
  12. use Mall\Framework\Core\ErrorCode;
  13. class SupplierCache
  14. {
  15. private $cache;
  16. protected $SupplierToken = 'SupplierToken';//供应商token
  17. public function __construct()
  18. {
  19. $this->cache = Factory::cache('default');
  20. }
  21. /**
  22. * 缓存供应商token
  23. * @param $enterpriseId
  24. * @param $supplierId
  25. * @param $token
  26. * @return bool
  27. */
  28. public function setSupplierToken($enterpriseId, $supplierId, $token)
  29. {
  30. return $this->cache->zadd($this->SupplierToken.'::'.$enterpriseId, $supplierId, $token);
  31. }
  32. /**
  33. * 根据token获取供应商id 反解token需要
  34. * @param $enterpriseId
  35. * @param $token
  36. * @return float
  37. */
  38. public function getSupplierToken($enterpriseId, $token)
  39. {
  40. return $this->cache->zscore($this->SupplierToken.'::'.$enterpriseId, $token);
  41. }
  42. }