UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NyQG9DH7CZbpH117j7K/ceTWV6tuSByB3eO3id/uS20=' 
WHERE 
  key_id = '58b46960db42fc14665c11e51f2b69136c91581366a1f3dce734ae9585545440' 
  AND (
    token = 'NyQG9DH7CZbpH117j7K/ceTWV6tuSByB3eO3id/uS20=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035