@@ -189,14 +189,14 @@ def __set_uuid_subtype(self, subtype):
189189 self .__uuid_subtype = subtype
190190
191191 uuid_subtype = property (__get_uuid_subtype , __set_uuid_subtype ,
192- doc = """This setting specifies which BSON Binary
192+ doc = """This attribute specifies which BSON Binary
193193 subtype is used when storing UUIDs. Historically
194194 UUIDs have been stored as BSON Binary subtype 3.
195- This setting is used to switch to the newer BSON
196- binary subtype 4. This setting can also be used to
197- force legacy byte order and subtype compatibility
198- with the Java and C# drivers. See the bson.binary
199- module for all options.""" )
195+ This attribute is used to switch to the newer BSON
196+ binary subtype 4. It can also be used to force
197+ legacy byte order and subtype compatibility with
198+ the Java and C# drivers. See the
199+ :mod:`bson.binary` module for all options.""" )
200200
201201 def __get_context (self ):
202202 return self .__context
@@ -659,7 +659,7 @@ def count(self):
659659 """
660660 return self .find ().count ()
661661
662- def create_index (self , key_or_list , ttl = 300 , ** kwargs ):
662+ def create_index (self , key_or_list , cache_for = 300 , ** kwargs ):
663663 """Creates an index on this collection.
664664
665665 Takes either a single key or a list of (key, direction) pairs.
@@ -696,13 +696,18 @@ def create_index(self, key_or_list, ttl=300, **kwargs):
696696 :Parameters:
697697 - `key_or_list`: a single key or a list of (key, direction)
698698 pairs specifying the index to create
699- - `ttl ` (optional): time window (in seconds) during which
699+ - `cache_for ` (optional): time window (in seconds) during which
700700 this index will be recognized by subsequent calls to
701701 :meth:`ensure_index` - see documentation for
702702 :meth:`ensure_index` for details
703703 - `**kwargs` (optional): any additional index creation
704704 options (see the above list) should be passed as keyword
705705 arguments
706+ - `ttl` (deprecated): Use `cache_for` instead.
707+
708+ .. versionchanged:: 2.3
709+ The `ttl` parameter has been deprecated to avoid confusion with
710+ TTL collections. Use `cache_for` instead.
706711
707712 .. versionchanged:: 2.2
708713 Removed deprecated argument: deprecated_unique
@@ -717,6 +722,12 @@ def create_index(self, key_or_list, ttl=300, **kwargs):
717722
718723 .. mongodoc:: indexes
719724 """
725+
726+ if 'ttl' in kwargs :
727+ cache_for = kwargs .pop ('ttl' )
728+ warnings .warn ("ttl is deprecated. Please use cache_for instead." ,
729+ DeprecationWarning )
730+
720731 keys = helpers ._index_list (key_or_list )
721732 index_doc = helpers ._index_document (keys )
722733
@@ -738,11 +749,11 @@ def create_index(self, key_or_list, ttl=300, **kwargs):
738749 safe = True )
739750
740751 self .__database .connection ._cache_index (self .__database .name ,
741- self .__name , name , ttl )
752+ self .__name , name , cache_for )
742753
743754 return name
744755
745- def ensure_index (self , key_or_list , ttl = 300 , ** kwargs ):
756+ def ensure_index (self , key_or_list , cache_for = 300 , ** kwargs ):
746757 """Ensures that an index exists on this collection.
747758
748759 Takes either a single key or a list of (key, direction) pairs.
@@ -788,12 +799,17 @@ def ensure_index(self, key_or_list, ttl=300, **kwargs):
788799 :Parameters:
789800 - `key_or_list`: a single key or a list of (key, direction)
790801 pairs specifying the index to create
791- - `ttl ` (optional): time window (in seconds) during which
802+ - `cache_for ` (optional): time window (in seconds) during which
792803 this index will be recognized by subsequent calls to
793804 :meth:`ensure_index`
794805 - `**kwargs` (optional): any additional index creation
795806 options (see the above list) should be passed as keyword
796807 arguments
808+ - `ttl` (deprecated): Use `cache_for` instead.
809+
810+ .. versionchanged:: 2.3
811+ The `ttl` parameter has been deprecated to avoid confusion with
812+ TTL collections. Use `cache_for` instead.
797813
798814 .. versionchanged:: 2.2
799815 Removed deprecated argument: deprecated_unique
@@ -814,7 +830,7 @@ def ensure_index(self, key_or_list, ttl=300, **kwargs):
814830
815831 if not self .__database .connection ._cached (self .__database .name ,
816832 self .__name , name ):
817- return self .create_index (key_or_list , ttl , ** kwargs )
833+ return self .create_index (key_or_list , cache_for , ** kwargs )
818834 return None
819835
820836 def drop_indexes (self ):
0 commit comments