code: def get_conn(opts, profile=None, host=None, port=None):
      '''
      Return a conn object for accessing memcached
      '''
      if not (host and port):
          opts_pillar = opts.get('pillar', {})
          opts_master = opts_pillar.get('master', {})
  
          opts_merged = {}
          opts_merged.update(opts_master)
          opts_merged.update(opts_pillar)
          opts_merged.update(opts)
  
          if profile:
              conf = opts_merged.get(profile, {})
          else:
              conf = opts_merged
  
          host = conf.get('memcached.host', DEFAULT_HOST)
          port = conf.get('memcached.port', DEFAULT_PORT)
  
      if not six.text_type(port).isdigit():
          raise SaltInvocationError('port must be an integer')
  
      if HAS_LIBS:
          return memcache.Client(['{0}:{1}'.format(host, port)])
      else:
          raise CommandExecutionError(
              '(unable to import memcache, '
              'module most likely not installed)'
          f get_conn(opts, profile=None, host=None, port=None):
      '''
      Return a conn object for accessing memcached
      '''
      if not (host and port):
          opts_pillar = opts.get('pillar', {})
          opts_master = opts_pillar.get('master', {})
  
          opts_merged = {}
          opts_merged.update(opts_master)
          opts_merged.update(opts_pillar)
          opts_merged.update(opts)
  
          if profile:
              conf = opts_merged.get(profile, {})
          else:
              conf = opts_merged
  
          host = conf.get('memcached.host', DEFAULT_HOST)
          port = conf.get('memcached.port', DEFAULT_PORT)
  
      if not six.text_type(port).isdigit():
          raise SaltInvocationError('port must be an integer')
  
      if HAS_LIBS:
          return memcache.Client(['{0}:{1}'.format(host, port)])
      else:
          raise CommandExecutionError(
              '(unable to import memcache, '
              'module most likely not installed)'
          )
docs: Return a conn object for accessing memcached