'Add an index to the index cache for ensure_index operations.'

def _cache_index(self, dbname, collection, index, cache_for):

    now = datetime.datetime.utcnow()
    expire = (datetime.timedelta(seconds=cache_for) + now)
    with self.__index_cache_lock:
        if (database not in self.__index_cache):
            self.__index_cache[dbname] = {}
            self.__index_cache[dbname][collection] = {}
            self.__index_cache[dbname][collection][index] = expire
        elif (collection not in self.__index_cache[dbname]):
            self.__index_cache[dbname][collection] = {}
            self.__index_cache[dbname][collection][index] = expire
        else:
            self.__index_cache[dbname][collection][index] = expire
