protected function getConfig() { $dataClass = new AbTestingData(); $memcKey = $this->getMemcKey(); // $data = $this->wg->memc->get($memcKey); if (empty($data)) { $data = array('modifiedTime' => $this->getTimestampForUTCDate($dataClass->getModifiedTime()), 'script' => $this->generateConfigScript($dataClass->getCurrent())); $this->wg->memc->set($memcKey, $data, self::CACHE_TTL); } return $data; }
protected function generateConfigObj($useMaster = false) { $dataClass = new AbTestingData(); $dataClass->setUseMaster($useMaster); $memcKey = $this->getMemcKey(); // find last modification time $lastModified = $dataClass->getLastEffectiveChangeTime(self::VARNISH_CACHE_TIME); $lastModified = $lastModified ? $this->getTimestampForUTCDate($lastModified) : null; // find time of next config change $nextModification = $dataClass->getNextEffectiveChangeTime(self::VARNISH_CACHE_TIME); $nextModification = $nextModification ? $this->getTimestampForUTCDate($nextModification) : null; // calculate proper TTL $ttl = self::CACHE_TTL; if ($nextModification) { $ttl = max(1, min($ttl, $nextModification - time() + 1)); } $externalData = array(); $script = $this->generateConfigScript($dataClass->getCurrent(), $externalData); $data = array('modifiedTime' => $lastModified, 'script' => $script, 'externalData' => $externalData); $this->wg->memc->set($memcKey, $data, $ttl); return $data; }