diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index cbafe39a95..d26a398f95 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -636,7 +636,7 @@ def _cache_index(self, dbname, collection, index, cache_for): expire = datetime.timedelta(seconds=cache_for) + now with self.__index_cache_lock: - if database not in self.__index_cache: + if dbname not in self.__index_cache: self.__index_cache[dbname] = {} self.__index_cache[dbname][collection] = {} self.__index_cache[dbname][collection][index] = expire