#NEWLINE# def __getitem__( self , host_port_string ) : #NEWLINE# #INDENT# '\n        Retrieve the item from the cache or resolve the hostname and store the\n        result in the cache.\n\n        Returns a tuple of `(ip, port)`. At the moment we only support IPv4 but\n        this will probably change in the future.\n        ' #NEWLINE# if ( host_port_string in self . _static_cache . keys ( ) ) : #NEWLINE# #INDENT# return self . _static_cache [ host_port_string ] #NEWLINE# #UNINDENT# if ( host_port_string not in self . _cache ) : #NEWLINE# #INDENT# ( hostname , port ) = host_port_string . split ( ':' ) #NEWLINE# infos = socket . getaddrinfo ( hostname , port , 0 , 0 , socket . SOL_TCP ) #NEWLINE# for ( _family , _socktype , _proto , _canoname , sockaddr ) in infos : #NEWLINE# #INDENT# if ( len ( sockaddr ) == 2 ) : #NEWLINE# #INDENT# self . _cache [ host_port_string ] = sockaddr #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return self . _cache [ host_port_string ]