// +---------------------------------------------------------------------- namespace App\Services\Common; use App\Models\CoinLogModel; use App\Services\BaseService; use App\Services\RedisService; /** * 币种明细(提币、存币)-服务类 * Class CoinLogService * @package App\Services\Common */ class CoinLogService extends BaseService { // 静态对象 protected static $instance = null; /** * 构造函数 * @since 2020/11/10 * CoinLogService constructor. */ public function __construct() { $this->model = new CoinLogModel(); } /** * 静态入口 * @return static|null */ public static function make() { if (!self::$instance) { self::$instance = (new static()); } return self::$instance; } /** * 验证是否存在 * @param \App\Services\字段名 $field * @param \App\Services\字段值 $value * @param string $pk * @return mixed */ public function checkExists($field, $value, $pk = 'id') { $cacheKey = "caches:coinLogs:exists:{$field}_{$value}"; if($result = RedisService::get($cacheKey)){ return $result; } $result = parent::checkExists($field, $value, $pk); if($result){ RedisService::set($cacheKey, $result, rand(3,5)); } return $result; } }