<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prepare(self, query, name=None):
 """Create and cache a prepared statement using the provided query. This function will take a ``query`` and optional ``name`` parameter and will create a new prepared statement for the provided ``query``. The resulting statement object will be cached so future invocations of this function will not incur the overhead or recreating the statement. If ``name`` is provided it will be used as the key for the cache, so you'll be able to call ``execute`` using the name. :pram str query: The query to prepare. :pram str name: (Optional) name to use as a key in the cache. """

        key = name or query
        stmt = CassandraConnection._prepared_statement_cache.get(key, None)
        if stmt is not None:
            return stmt

        stmt = self._session.prepare(query)
        CassandraConnection._prepared_statement_cache[key] = stmt
        return stmt