예제 #1
0
 private function minivardump($vars)
 {
     if (count($vars) == 0) {
         return;
     }
     $varCnt = 0;
     foreach ($vars as $var) {
         if (is_string($var)) {
             if (strlen($var) > 20) {
                 echo '<span title="' . h($var) . '">\'' . h(substr($var, 0, 20)) . '\'...</span>';
             } else {
                 echo "'" . h($var) . "'";
             }
         } else {
             if (is_numeric($var)) {
                 echo h($var);
             } else {
                 echo h(kataFunc::getValueInfo($var));
             }
         }
         $varCnt++;
         if ($varCnt > 2 && count($vars) > 2) {
             echo '...';
             break;
         }
         if ($varCnt < count($vars)) {
             echo ', ';
         }
     }
 }
 /**
  * read multiple keys at once
  * @param array $ids keynames
  * @param string|bool $forceMethod which method to use
  * @return array
  */
 public function getMulti($ids, $forceMethod = false)
 {
     if (DEBUG > 2) {
         foreach ($ids as $id) {
             $this->results[] = array(kataFunc::getLineInfo(), 'read', $ids, '*caching off*', 0);
         }
         return false;
     }
     $startTime = microtime(true);
     $this->initialize();
     foreach ($ids as &$id) {
         $id = CACHE_IDENTIFIER . '-' . $id;
     }
     unset($id);
     if (false === $forceMethod) {
         $this->method = $this->defaultMethod;
     } else {
         $this->method = $forceMethod;
     }
     if (self::CM_MEMCACHED == $this->method) {
         $this->initMemcached(true);
         $r = $this->memcachedClass->getMulti($ids);
         if (DEBUG > 0) {
             $endTime = microtime(true) - $startTime;
             foreach ($ids as $no => $id) {
                 $this->results[] = array(kataFunc::getLineInfo(), 'read', $id, kataFunc::getValueInfo($r[$no]), $endTime);
             }
         }
         if ($this->useRequestCache) {
             foreach ($ids as $id) {
                 $this->requestCache[$id] = $r[$id];
             }
         }
         return $r;
     }
     throw new Exception('ExtCacheUtil: getMulti works only with memcache(d)');
 }
예제 #3
0
 function read($id, $forceMethod = false)
 {
     if (DEBUG > 2) {
         $this->results[] = array(kataFunc::getLineInfo(), 'read', $id, '*caching off*', 0);
         return false;
     }
     if ($this->useRequestCache && isset($this->requestCache[$id])) {
         $data = $this->requestCache[$id];
         if (DEBUG > 0) {
             $this->results[] = array(kataFunc::getLineInfo(), 'reqCache', $id, kataFunc::getValueInfo($data), 0);
         }
         return $data;
     }
     $startTime = microtime(true);
     $this->initialize();
     $data = $this->_read($id, $forceMethod);
     if (DEBUG > 0) {
         $this->results[] = array(kataFunc::getLineInfo(), 'read', $id, kataFunc::getValueInfo($data), microtime(true) - $startTime);
     }
     if ($this->useRequestCache) {
         $this->requestCache[$id] = $data;
     }
     return $data;
 }