123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * Created by PhpStorm.
- * User: phperstar
- * Date: 2020/11/6
- * Time: 11:22 AM
- */
- namespace Service\Order\Cache;
- use function FastRoute\TestFixtures\empty_options_cached;
- use Mall\Framework\Factory;
- class OrderCache
- {
- /**
- * 连接id和店铺id映射关系缓存
- *
- * @var
- */
- static $webstockConnect = 'webstockConnect';
- /**
- * 判断所有表名缓存是否存在
- *
- * @param string $databaseName 库名
- *
- * @return bool
- */
- static function allTableNameCacheIsExists($databaseName){
- $result = Factory::cache('backend')->has(self::$allTableName.'::'.$databaseName);
- return $result;
- }
- /**
- * 缓存制定库下的所有表名
- *
- * @param string $dataBaseName 当前数据库库名
- * @param array $allTableNameData 当前库中所有表名数据
- */
- static function allTableNameCache($databaseName, $allTableNameData)
- {
- if(empty($allTableNameData)){
- return false;
- }
- $pipe = Factory::cache('backend')->multi();
- foreach ($allTableNameData as $key => $value){
- $writeCache = Factory::cache('backend')->sadd(self::$allTableName.'::'.$databaseName, $value['TABLE_NAME']);
- }
- $pipe->exec();
- }
- /**
- * 添加新的连接到缓存中
- * @param int webstockFromId 连接来源标识id
- * @param string shopMake 店铺标识
- *
- * @return bool
- */
- static function addWebstockFromIdAndShopId($platfrom,$shopId,$userId,$fromId)
- {
- $key = self::$webstockConnect.'::'.$platfrom.'::'.$shopId;
- // 用户和webstock链接映射关系
- $writeCache = Factory::cache('default')->hset($key, $userId, $fromId);
- return $key;
- }
- /**
- * 获取店铺对应的webstock id标识
- * @param string shopMake 店铺标识
- *
- * @return bool
- */
- static function getWebstockFromIdAndShopId($platfrom,$shopId)
- {
- $key = self::$webstockConnect.'::'.$platfrom.'::'.$shopId;
- return Factory::cache('default')->hvalues($key);
- }
- }
|