@@ 699-727 (lines=29) @@ | ||
696 | * |
|
697 | * @return bool|null|string |
|
698 | */ |
|
699 | public static function cache($name, $value = '', $expires = 0) |
|
700 | { |
|
701 | if (!$name || !is_string($name)) { |
|
702 | self::setError('参数错误!'); |
|
703 | ||
704 | return false; |
|
705 | } |
|
706 | ||
707 | /** @var BaseDriver $cacheDriver */ |
|
708 | static $cacheDriver; |
|
709 | ||
710 | if (!isset($cacheDriver)) { |
|
711 | $cacheDriver = __NAMESPACE__ . '\\CacheDriver\\' . self::$CACHE_DRIVER . 'Driver'; |
|
712 | $cacheDriver = new $cacheDriver(__DIR__ . '/Cache/'); |
|
713 | } |
|
714 | ||
715 | if (!$value && $value !== 0) { |
|
716 | $value = $cacheDriver->_get($name); |
|
717 | if (false == $value) { |
|
718 | $value = null; |
|
719 | } |
|
720 | ||
721 | return $value; |
|
722 | } |
|
723 | ||
724 | $res = $cacheDriver->_set($name, $value, $expires); |
|
725 | ||
726 | return $res ? true : false; |
|
727 | } |
|
728 | } |
|
729 |
@@ 585-613 (lines=29) @@ | ||
582 | * |
|
583 | * @return bool|null|string |
|
584 | */ |
|
585 | public static function cache($name, $value = '', $expires = 0) |
|
586 | { |
|
587 | if (!$name || !is_string($name)) { |
|
588 | self::setError('参数错误!'); |
|
589 | ||
590 | return false; |
|
591 | } |
|
592 | ||
593 | /** @var BaseDriver $cacheDriver */ |
|
594 | static $cacheDriver; |
|
595 | ||
596 | if (!isset($cacheDriver)) { |
|
597 | $cacheDriver = __NAMESPACE__ . '\\CacheDriver\\' . self::$CACHE_DRIVER . 'Driver'; |
|
598 | $cacheDriver = new $cacheDriver(__DIR__ . '/Cache/'); |
|
599 | } |
|
600 | ||
601 | if (!$value && $value !== 0) { |
|
602 | $value = $cacheDriver->_get($name); |
|
603 | if (false == $value) { |
|
604 | $value = null; |
|
605 | } |
|
606 | ||
607 | return $value; |
|
608 | } |
|
609 | ||
610 | $res = $cacheDriver->_set($name, $value, $expires); |
|
611 | ||
612 | return $res ? true : false; |
|
613 | } |
|
614 | ||
615 | //token 刷新后重试 post |
|
616 | public static function post_retry($apiUrl, $data) |