<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_connection(self, service_name):
 """ Retrieves a connection class from the cache, if available. :param service_name: The service a given ``Connection`` talks to. Ex. ``sqs``, ``sns``, ``dynamodb``, etc. :type service_name: string :returns: A <kotocore.connection.Connection> subclass """

        service = self.services.get(service_name, {})
        connection_class = service.get('connection', None)

        if not connection_class:
            msg = "Connection for '{0}' is not present in the cache."
            raise NotCached(msg.format(
                service_name
            ))

        return connection_class