12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * 收藏缓存
- * Created by PhpStorm.
- * User: wxj
- * Date: 2019/11/5
- * Time: 10:14
- */
- namespace JinDouYun\Cache;
- use Mall\Framework\Cache\Redis;
- use Mall\Framework\Factory;
- class CollectCache
- {
- /**
- * @var Redis
- */
- private $cache;
- protected $CollectKey = 'Collect';
- public function __construct()
- {
- $this->cache = Factory::cache('user');
- }
- /**
- * 缓存收藏
- * @param $enterpriseId
- * @param $userCenterId
- * @param $goodsId
- * @return
- */
- public function cacheCollect($enterpriseId, $userCenterId, $goodsId)
- {
- $this->cache->sadd($this->CollectKey.'::'.$enterpriseId.'::'.$userCenterId, $goodsId);
- }
- public function getCollect($enterpriseId, $userCenterId, $goodsId) {
- return $this->cache->sismember($this->CollectKey.'::'.$enterpriseId.'::'.$userCenterId, $goodsId);
- }
- public function delCollect($enterpriseId, $userCenterId, $goodsId) {
- return $this->cache->srem($this->CollectKey.'::'.$enterpriseId.'::'.$userCenterId, $goodsId);
- }
- public function getCollectList($enterpriseId,$userCenterId)
- {
- return $this->cache->smembers($this->CollectKey.'::'.$enterpriseId.'::'.$userCenterId);
- }
- }
|