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

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • 2.2.1
    • 2.3.0
    • Public API
    • Major Change

    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

            emily.stolfo Emily Stolfo
            robert@80beans.com Robert Beekman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: