UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'b74NetEar2z7mZLBA+jUZi2ruT33u26/rdDCcNQN+zY=' 
WHERE 
  key_id = '10ecbac462365850f525b2b75bb7cad09fa0757c3a4e73449146dd2daef9281b' 
  AND (
    token = 'b74NetEar2z7mZLBA+jUZi2ruT33u26/rdDCcNQN+zY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035