UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'nGJuh3G2gCMrao5TlGErmzIgf+i0AhPuXrSCphCxMJU=' 
WHERE 
  key_id = '04e40160ec5f584e731ad82bbd105bdc4f3025edf0e745cd24079e1d639bee29' 
  AND (
    token = 'nGJuh3G2gCMrao5TlGErmzIgf+i0AhPuXrSCphCxMJU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00046