UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'BM0XcchAOipSH9Lj8MLMuTtX+XToV/MhPhzsRoy7rwc=' 
WHERE 
  key_id = '217038bd660ee85ca073abf40e33498fa6b500fc2ee8173ebae985937e56c5cc' 
  AND (
    token = 'BM0XcchAOipSH9Lj8MLMuTtX+XToV/MhPhzsRoy7rwc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035