Example #1
0
 /**
  * Initialize the shared memory
  *
  * @return void
  */
 static function init()
 {
     global $dPconfig;
     // Must be the same here and in CApp
     // We don't use CApp because it can be called in /install
     $root_dir = $dPconfig['root_dir'];
     $prefix = preg_replace("/[^\\w]+/", "_", $root_dir);
     self::$prefix = "{$prefix}-";
     /* ----- Local shared memory ----- */
     $engine_name = $dPconfig['shared_memory'];
     if (!isset(self::$availableEngines[$engine_name])) {
         $engine_name = "disk";
     }
     $class_name = self::$availableEngines[$engine_name];
     include_once __DIR__ . "/shm/{$class_name}.class.php";
     /** @var ISharedMemory $engine */
     $engine = new $class_name();
     if (!$engine->init()) {
         $class_name = self::$availableEngines["disk"];
         include_once __DIR__ . "/shm/{$class_name}.class.php";
         $engine = new $class_name();
         $engine->init();
     }
     self::$engine = $engine;
     /* ----- Multi server shared memory ----- */
     $engine_name_distributed = $dPconfig['shared_memory_distributed'];
     if (!$engine_name_distributed || !isset(self::$availableEngines[$engine_name_distributed])) {
         $engine_name_distributed = $engine_name;
     }
     $class_name = self::$availableEngines[$engine_name_distributed];
     include_once __DIR__ . "/shm/{$class_name}.class.php";
     /** @var ISharedMemory $engine_distributed */
     $engine_distributed = new $class_name();
     if (!$engine_distributed->init()) {
         $class_name = self::$availableEngines["disk"];
         include_once __DIR__ . "/shm/{$class_name}.class.php";
         $engine_distributed = new $class_name();
         $engine_distributed->init();
     }
     self::$engineDistributed = $engine_distributed;
 }