You are here

function mongodb_session_ensure_indexes in MongoDB 7

Create an index for the session collection.

3 calls to mongodb_session_ensure_indexes()
mongodb_session_enable in mongodb_session/mongodb_session.install
Implements hook_enable().
mongodb_session_install in mongodb_session/mongodb_session.install
Implements hook_install().
mongodb_session_update_7000 in mongodb_session/mongodb_session.install
Build indexes on session table.

File

mongodb_session/mongodb_session.install, line 25
MongoDB session install file.

Code

function mongodb_session_ensure_indexes() {
  $collection = mongodb_collection(variable_get('mongodb_session', 'session'));
  $index = array(
    'sid' => 1,
  );
  $collection
    ->ensureIndex($index);
  $index = array(
    'ssid' => 1,
  );
  $collection
    ->ensureIndex($index);
  $index = array(
    'uid' => 1,
  );
  $collection
    ->ensureIndex($index);
  $index = [
    'timestamp' => -1,
  ];
  $collection
    ->ensureIndex($index);
}