UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ivGJdJdshhIUsseJ5YymL2NEesqoo6YAVuB13N2b6Ao=' 
WHERE 
  key_id = '040dec7f4d6916ed82d8d2817ecb2e8c30a4931f60dc080bfdbe1f22e554d46c' 
  AND (
    token = 'ivGJdJdshhIUsseJ5YymL2NEesqoo6YAVuB13N2b6Ao=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037