@@ -238,16 +238,12 @@ This store does not support blocking, and expects a TTL to avoid stalled locks::
238238
239239The ``MongoDbStore `` takes the following ``$options ``:
240240
241- =============== =============== ===================================================================================
242- Option Default Description
243- =============== =============== ===================================================================================
244- database The name of the database [Mandatory]
245- collection ``lock `` The name of the collection
246- resource_field ``_id `` The field name for storing the lock id **MUST be uniquely indexed if you chage it **
247- token_field ``token `` The field name for storing the lock token
248- acquired_field ``acquired_at `` The field name for storing the acquisition timestamp
249- expiry_field ``expires_at `` The field name for storing the expiry-timestamp
250- =============== =============== ===================================================================================
241+ =========== ========= ====================================
242+ Option Default Description
243+ =========== ========= ====================================
244+ database The name of the database [Mandatory]
245+ collection ``lock `` The name of the collection
246+ =========== ========= ====================================
251247
252248.. _lock-store-redis :
253249
@@ -468,21 +464,25 @@ method uses the Memcached's ``flush()`` method which purges and removes everythi
468464MongoDbStore
469465~~~~~~~~~~~~
470466
471- The MongoDbStore relies on a unique index on the ``<resource_field> ``. By default
472- this is ``_id `` which already has a unique index being the collection identifier.
473- It is strongly recommended to leave this as is. If you do need to change the
474- ``<resource_field> `` you **MUST ** ensure you place a unique index on your filed.
467+ An indexed field's value in MongoDB can be a maximum of 1024 bytes in length
468+ inclusive of structural overhead.
475469
476- It's possible to automatically expire the locks in the database as described below:
470+ For more details see: https://docs.mongodb.com/manual/reference/limits/#Index-Key-Limit
477471
478- A TTL index can be used on MongoDB 2.2+ to cleanup expired locks
479- automatically. Such an index can for example look like this:
472+ A TTL index MUST BE used on MongoDB 2.2+ to automatically clean up expired locks.
473+ Please be aware any clock drift between the application and mongo servers could
474+ cause locks to be released prematurely. To account for any drift;
475+ expireAfterSeconds can be set to a value higher than 0. The logical expiry of
476+ locks is handled by the application so setting a higher ``expireAfterSeconds ``
477+ has no effect other than keeping stale data for longer.
478+
479+ Such an index can for example look like this:
480480
481481.. code-block :: javascript
482482
483- db.< lock- collection > .ensureIndex (
484- { " <expiry-field> " : 1 },
485- { " expireAfterSeconds" : 0 }
483+ db .lock .ensureIndex (
484+ { " expires_at " : 1 },
485+ { " expireAfterSeconds" : 60 }
486486 )
487487
488488 For more details see: http://docs.mongodb.org/manual/tutorial/expire-data/
0 commit comments