public function MongoDbSessionHandler::gc

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php, line 102

Class

MongoDbSessionHandler
MongoDB session handler

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

public function gc($lifetime) {

  /* Note: MongoDB 2.2+ supports TTL collections, which may be used in
   * place of this method by indexing the "time_field" field with an
   * "expireAfterSeconds" option. Regardless of whether TTL collections
   * are used, consider indexing this field to make the remove query more
   * efficient.
   *
   * See: http://docs.mongodb.org/manual/tutorial/expire-data/
   */
  $time = new \MongoDate(time() - $lifetime);
  $this
    ->getCollection()
    ->remove(array(
    $this->options['time_field'] => array(
      '$lt' => $time,
    ),
  ));
  return true;
}