<?php
namespace DAO;
/**
 * User: liuyuzhen
 * Date: 2018/8/20
 * Time: 10:15
 * Description:
 */
class LockModel extends \DAO\AbstractModel{
    public function init(){

    }

    public function getLock($key, $timeout)
    {
        $sql = "SELECT GET_LOCK('".$key."', '".$timeout."')";
        $res =  $this->db->query($sql);
        return $res;
    }

    public function releaseLock($key)
    {
        $sql = "SELECT RELEASE_LOCK('".$key."')";
        return $this->db->query($sql);
    }
    /**
     * 类实例
     *
     * @var \DAO\UserModel
     */
    private static $_instance = null;

    /**
     * 获取类实例
     *
     * @return \DAO\UserModel
     */
    public static function getInstance($dbName = \Our\DbNameConst::salveDBConnectName) {
        if (!(self::$_instance instanceof self)) {
            self::$_instance = new self($dbName);
        }

        return self::$_instance;
    }
}