public function initialise(cache_definition $definition) {
        if ($this->is_initialised()) {
            throw new coding_exception('This mongodb instance has already been initialised.');
        }
        $this->database = $this->connection->selectDatabase($this->databasename);
        $this->definitionhash = 'm'.$definition->generate_definition_hash();
        $this->collection = $this->database->selectCollection($this->definitionhash);

        $options = array('name' => 'idx_key');

        $w = $this->usesafe ? 1 : 0;
        $wc = new MongoDB\Driver\WriteConcern($w);

        $options['writeConcern'] = $wc;

        $this->collection->createIndex(array('key' => 1), $options);
    }