You are here

public function Cache::__construct in MongoDB 7

Constructor.

Parameters

string $bin: The name of the cache bin for which to build a backend.

1 method overrides Cache::__construct()
MockBin::__construct in mongodb_cache/src/Tests/CacheUnitTestCase.php
MockBin constructor.

File

mongodb_cache/mongodb_cache_plugin.php, line 88

Class

Cache
MongoDB cache implementation.

Namespace

Drupal\mongodb_cache

Code

public function __construct($bin) {
  $this->bin = $bin;
  try {
    $this->collection = mongodb_collection($bin);
  } catch (\MongoConnectionException $e) {
    static::notifyException($e);
    $this->collection = new \MongodbDummy();
  }

  // Default is FALSE: this is a cache, so a missed write is not an issue.
  $this->unsafe = mongodb_default_write_options(FALSE);
  $this->stampedeDelay = variable_get('mongodb_cache_stampede_delay', 5);
  $this->flushVarName = "flush_cache_{$bin}";
  $this->binDataCreator = $this
    ->getBinDataCreator();
}