Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1083

Support "expire_after_seconds" in addition to "expire_after" in index view

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.3.0
    • Component/s: Public API
    • Labels:
    • Backwards Compatibility:
      Major Change
    • Epic Link:
    • Sprint:
      Ruby Sprint 31

      Description

      Right now in the index view there's a mapping that maps expire_after to expireAfterSeconds.
      ( https://github.com/mongodb/mongo-ruby-driver/blob/b61d29c2f9b2c62cab5345c550f51b2b216d925c/lib/mongo/index/view.rb#L53 )

      This means that to create an index that uses a ttl for a collection, you need to set the expire_after option, e.g.:

      ```
      .collection.indexes.create_one(
      {:time => 1},
      {:expire_after => 86400}
      )
      ```

      This is inconsistent with the other mappings that are just `.underscore`-ed versions of the MongoDB params.

      To make things more confusing, in Mongoid, this mapping is reversed with another mapping, so there the value is `expire_after_seconds`.

      ( https://github.com/mongodb/mongoid/blob/9fca9c254afbb38a0ead1d6133edea683f63ba35/lib/mongoid/indexable/specification.rb#L14 )

      And finally the `expire_after_seconds` or `expireAfterSeconds` option is silently dropped when creating an index, causing potentially enormous database growth.

      In order to keep things consistent across the database, ruby driver and Mongoid, it would be better to rename `expire_after` to `expire_after_seconds`.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: