1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace JinDouYun\Cache;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Factory;
- class PageCache
- {
- private $cache;
-
- private $enterpriseId;
-
- private $userCenterId;
-
- private $cacheKey = 'Page';
-
- public function __construct($enterpriseId = false, $userCenterId = false)
- {
- $this->enterpriseId = $enterpriseId;
- $this->userCenterId = $userCenterId;
- $this->cache = Factory::cache('default');
- }
-
-
-
-
- public function addPage($md5Key, $pageData)
- {
- $data = json_encode($pageData);
- $result = $this->cache->hset($this->cacheKey, $md5Key, $data);
- if(!$result){
- return false;
- }
- return true;
- }
-
-
- public function getPage($md5Key)
- {
- $result = $this->cache->hget($this->cacheKey, $md5Key);
- if (!$result) return [];
- $returnData = json_decode($result, true);
-
- return $returnData;
- }
-
-
- public function delPage($paegId = false)
- {
- if($paegId){
- $this->cache->hdel($this->cacheKey, $paegId);
- }else{
- $this->cache->del($this->cacheKey);
- }
- }
-
- }
|