コード例 #1
0
ファイル: fichas.php プロジェクト: e-gob/ChileAtiende
 function ver($id)
 {
     redirect(site_url('fichas/ver/' . $id), 'location', 301);
     if (!($data = apc_fetch('movil_fichas_ver_data' . $id))) {
         $data['theme_page'] = "d";
         $data['theme_header'] = "a";
         $ficha = Doctrine::getTable('Ficha')->findPublicado($id);
         if ($ficha[0]->titulo) {
             $data['title'] = $ficha[0]->titulo;
             if ($ficha[0]->flujo) {
                 $data['content'] = 'movil/verflujo';
             } else {
                 $data['content'] = 'movil/verficha';
             }
             $data['vista_ficha'] = true;
             $data['ficha'] = $ficha[0];
             if ($this->config->item('cache')) {
                 apc_store('movil_fichas_ver_data' . $id, $data, 60 * $this->config->item('cache'));
             }
         } else {
             redirect('movil/ficha/error/');
         }
     }
     $this->load->view('movil/template', $data);
 }
コード例 #2
0
ファイル: apc.php プロジェクト: guozqiu/think
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return bool
  */
 public function set($name, $value, $expire = null)
 {
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     if ($result = apc_store($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $queue = apc_fetch('__info__');
             if (!$queue) {
                 $queue = [];
             }
             if (false === array_search($name, $queue)) {
                 array_push($queue, $name);
             }
             if (count($queue) > $this->options['length']) {
                 // 出列
                 $key = array_shift($queue);
                 // 删除缓存
                 apc_delete($key);
             }
             apc_store('__info__', $queue);
         }
     }
     return $result;
 }
コード例 #3
0
ファイル: sfAPCCache.class.php プロジェクト: Phennim/symfony1
 /**
  * @see sfCache
  */
 public function set($key, $data, $lifetime = null)
 {
     if (!$this->enabled) {
         return true;
     }
     return apc_store($this->getOption('prefix') . $key, $data, $this->getLifetime($lifetime));
 }
コード例 #4
0
ファイル: binary_search.php プロジェクト: superego546/SMSGyan
 public function __construct($table, $field, $min, $condition = "", $cacheName = "")
 {
     if (empty($cacheName) || $cacheName == "") {
         $cacheName = $table;
     }
     $this->array = apc_fetch($cacheName, $success);
     if (!$success) {
         echo "{$table} FROM DATABASE";
         if (!empty($condition)) {
             echo $query = "select {$field} from {$table} where {$condition} order by {$field}";
         } else {
             echo $query = "select {$field} from {$table} order by {$field}";
         }
         $result = mysql_query($query) or trigger_error(mysql_error(), E_USER_ERROR);
         if (mysql_num_rows($result)) {
             echo "Sucess";
             $this->array = array();
             while ($row = mysql_fetch_array($result)) {
                 $this->array[] = strtolower($row[$field]);
             }
             apc_store($cacheName, $this->array);
         }
     }
     $this->count = count($this->array);
     $this->min = $min;
 }
コード例 #5
0
function query($type)
{
    if (!is_null($type)) {
        //get parameter data
        $parameters = Flight::request()->query->getData();
        $cacheKey = $type . json_encode($parameters);
        if (apc_exists($cacheKey)) {
            echo apc_fetch($cacheKey);
        } else {
            $url = 'http://localhost:8080/sparql';
            $query_string = file_get_contents('queries/' . $type . '.txt');
            foreach ($parameters as $key => $value) {
                $query_string = str_replace('{' . $key . '}', $value, $query_string);
            }
            //open connection
            $ch = curl_init();
            //set the url, number of POST vars, POST data
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/sparql-query"));
            curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            //execute post
            $result = curl_exec($ch);
            //close connection
            curl_close($ch);
            apc_store($cacheKey, $result);
            echo $result;
        }
    }
}
コード例 #6
0
ファイル: Apc.php プロジェクト: BGCX261/zr4u-svn-to-git
 public function set($id, $data, array $tags = NULL, $lifetime)
 {
     if (!empty($tags)) {
         throw new LemonRuntimeException('Cache: tags are unsupported by the APC driver', 500);
     }
     return apc_store($id, $data, $lifetime);
 }
コード例 #7
0
ファイル: Cache.php プロジェクト: eghojansu/moe
 /**
  *	Store value in cache
  *	@return mixed|FALSE
  *	@param $key string
  *	@param $val mixed
  *	@param $ttl int
  **/
 function set($key, $val, $ttl = 0)
 {
     $fw = Base::instance();
     if (!$this->dsn) {
         return TRUE;
     }
     $ndx = $this->prefix . '.' . $key;
     $time = microtime(TRUE);
     if ($cached = $this->exists($key)) {
         list($time, $ttl) = $cached;
     }
     $data = $fw->serialize(array($val, $time, $ttl));
     $parts = explode('=', $this->dsn, 2);
     switch ($parts[0]) {
         case 'apc':
         case 'apcu':
             return apc_store($ndx, $data, $ttl);
         case 'redis':
             return $this->ref->set($ndx, $data, array('ex' => $ttl));
         case 'memcache':
             return memcache_set($this->ref, $ndx, $data, 0, $ttl);
         case 'wincache':
             return wincache_ucache_set($ndx, $data, $ttl);
         case 'xcache':
             return xcache_set($ndx, $data, $ttl);
         case 'folder':
             return $fw->write($parts[1] . $ndx, $data);
     }
     return FALSE;
 }
コード例 #8
0
function get_sensor_name_list () {
	
	$sensor_list = apc_fetch('sensor_list');
	//var_dump($sensor_list);
		
	if (!$sensor_list) // if not available in APC then read the list from DB, then save the list in APC  
		{
			//echo "must read sesnor list from db";  
			
			$static_db = open_static_data_db(true);
			$results = $static_db->query('SELECT * FROM sensor_names;');
			while ($row = $results->fetchArray()) {
				$sensor_id = $row['id'];
				$sensor_name = $row['sensor_name'];
				$sensor_list[$sensor_id] = $sensor_name;
				//var_dump($sensor_list);
				// save the sensor list in APC	
			}
			$static_db->close();
			apc_store('sensor_list', $sensor_list);
	}
	
	return $sensor_list;
	
}
コード例 #9
0
function getClassPath()
{
    static $classpath = array();
    if (!empty($classpath)) {
        return $classpath;
    }
    if (function_exists("apc_fetch")) {
        $classpath = apc_fetch("fw:root:autoload:map:1397705849");
        if ($classpath) {
            return $classpath;
        }
        $classpath = getClassMapDef();
        apc_store("fw:root:autoload:map:1397705849", $classpath);
    } else {
        if (function_exists("eaccelerator_get")) {
            $classpath = eaccelerator_get("fw:root:autoload:map:1397705849");
            if ($classpath) {
                return $classpath;
            }
            $classpath = getClassMapDef();
            eaccelerator_put("fw:root:autoload:map:1397705849", $classpath);
        } else {
            $classpath = getClassMapDef();
        }
    }
    return $classpath;
}
コード例 #10
0
ファイル: autoload.include.php プロジェクト: roncemer/pfmgr2
 function __jax__loadClass($class_name)
 {
     global $__CLASS_AUTO_LOAD_CLASS_PATHS, $__CLASS_AUTO_LOAD_PATH_CACHE_TIMEOUT;
     $cacheKey = 'classAutoload:' . sha1($_SERVER['DOCUMENT_ROOT']) . ':' . $class_name;
     if (function_exists('apc_fetch')) {
         $path = @apc_fetch($cacheKey, $success);
     } else {
         $path = null;
         $success = false;
     }
     if (!$success) {
         foreach ($__CLASS_AUTO_LOAD_CLASS_PATHS as $dir) {
             $path = __jax__classAutoloadFindClassFile($class_name, $dir);
             if ($path !== false) {
                 if (function_exists('apc_add')) {
                     @apc_add($cacheKey, $path, $__CLASS_AUTO_LOAD_PATH_CACHE_TIMEOUT);
                 } else {
                     if (function_exists('apc_store')) {
                         @apc_store($cacheKey, $path, $__CLASS_AUTO_LOAD_PATH_CACHE_TIMEOUT);
                     }
                 }
                 break;
             }
         }
     }
     if ($path !== false) {
         include $path;
     }
 }
コード例 #11
0
ファイル: Apc.php プロジェクト: Kevin-ZK/vaneDisk
 /**
  * @inheritDoc
  */
 public function set($key, $value)
 {
     $rc = apc_store($key, array('time' => time(), 'data' => $value));
     if ($rc == false) {
         throw new Google_Cache_Exception("Couldn't store data");
     }
 }
コード例 #12
0
ファイル: ApcCachesource.php プロジェクト: nylmarcos/estagio
 /**
  * Escreve dados no cache
  * @param	string	$key	chave em que será gravado o cache
  * @param	mixed	$data	dados a serem gravados
  * @param	int		$time	tempo, em minutos, que o cache existirá
  * @return	boolean			retorna true se o cache for gravado com sucesso, no contrário, retorna false
  */
 public function write($key, $data, $time = 1)
 {
     $file = array();
     $file['time'] = time() + $time * minute;
     $file['data'] = $data;
     return apc_store(md5($key), $file);
 }
コード例 #13
0
 public static function getIdByStrId($strId)
 {
     // try to get strId to id mapping form cache
     $cacheKey = 'UserRolePeer_role_str_id_' . $strId;
     if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
         $id = apc_fetch($cacheKey);
         // try to fetch from cache
         if ($id) {
             KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - fetched from cache");
             return $id;
         }
     }
     // not found in cache - get from database
     $c = new Criteria();
     $c->addSelectColumn(UserRolePeer::ID);
     $c->addAnd(UserRolePeer::STR_ID, $strId, Criteria::EQUAL);
     $c->setLimit(1);
     $stmt = UserRolePeer::doSelectStmt($c);
     $id = $stmt->fetch(PDO::FETCH_COLUMN);
     if ($id) {
         // store the found id in cache for later use
         if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
             $success = apc_store($cacheKey, $id, kConf::get('apc_cache_ttl'));
             if ($success) {
                 KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - stored in cache");
             }
         }
     }
     if (!$id) {
         KalturaLog::log("UserRole with str_id [{$strId}] not found in DB!");
     }
     return $id;
 }
コード例 #14
0
ファイル: player_p2.php プロジェクト: samirios1/niter
function loguear($is_cache)
{
    global $link, $original_req, $log_active;
    if ($log_active) {
        $cache_key2 = "IPsLog";
        $cache = apc_fetch($cache_key2, $susses);
        $link_log = $original_req;
        if ($original_req != $link) {
            $link_log = $original_req . " -> " . $link;
        }
        if ($is_cache) {
            $link_log = "(from cache)" . $link_log;
        }
        $add = "(IP: " . $_SERVER['REMOTE_ADDR'] . ") " . $link_log . "\n [header: " . getallheaders() . "]";
        if ($susses) {
            apc_store($cache_key2, $cache . "\n\n" . $add, 1800);
        } else {
            apc_store($cache_key2, $add, 1800);
        }
        $cache_key2 = "IPsLogExcel";
        $cache = apc_fetch($cache_key2, $susses);
        $add = $_SERVER['REMOTE_ADDR'] . "\t" . $original_req . "\t" . $link . "\t" . $_SERVER['HTTP_REFERER'] . "\n";
        if ($susses) {
            apc_store($cache_key2, $cache . $add, 1800);
        } else {
            $add = "IP\tOriginal request\tRequest Procesado\tReferer\n" . $add;
            apc_store($cache_key2, $add, 1800);
        }
    }
}
コード例 #15
0
 /**
  * @param string $ClassName
  *
  * @return bool
  */
 public function loadClass($ClassName)
 {
     if ($this->checkExists($ClassName)) {
         return true;
     }
     if (function_exists('apc_fetch')) {
         $Hash = sha1($this->Namespace . $this->Path . $this->Separator . $this->Extension . $this->Prefix);
         // @codeCoverageIgnoreStart
         if (false === ($Result = apc_fetch($Hash . '#' . $ClassName))) {
             $Result = $this->checkCanLoadClass($ClassName);
             apc_store($Hash . '#' . $ClassName, $Result ? 1 : 0);
         }
         if (!$Result) {
             return false;
         }
     } else {
         // @codeCoverageIgnoreEnd
         if (!$this->checkCanLoadClass($ClassName)) {
             return false;
         }
     }
     /** @noinspection PhpIncludeInspection */
     require $this->Path . DIRECTORY_SEPARATOR . trim(str_replace(array($this->Prefix . $this->Separator, $this->Separator), array('', DIRECTORY_SEPARATOR), $ClassName), DIRECTORY_SEPARATOR) . $this->Extension;
     return $this->checkExists($ClassName);
 }
コード例 #16
0
ファイル: cache.php プロジェクト: niksfish/Tinyboard
 public static function set($key, $value, $expires = false)
 {
     global $config;
     $key = $config['cache']['prefix'] . $key;
     if (!$expires) {
         $expires = $config['cache']['timeout'];
     }
     switch ($config['cache']['enabled']) {
         case 'memcached':
             if (!self::$cache) {
                 self::init();
             }
             self::$cache->set($key, $value, $expires);
             break;
         case 'apc':
             apc_store($key, $value, $expires);
             break;
         case 'xcache':
             xcache_set($key, $value, $expires);
             break;
         case 'php':
             self::$cache[$key] = $value;
             break;
     }
 }
コード例 #17
0
ファイル: playlist.php プロジェクト: opshu/nginx-vod-module
function getDurationMillis($filePath)
{
    global $ffprobeBin;
    // try to fetch from cache
    $cacheKey = "duration-{$filePath}";
    $duration = apc_fetch($cacheKey);
    if ($duration) {
        return $duration;
    }
    // execute ffprobe
    $commandLine = "{$ffprobeBin} -i {$filePath} -show_streams -print_format json -v quiet";
    $output = null;
    exec($commandLine, $output);
    // parse the result - take the shortest duration
    $ffmpegResult = json_decode(implode("\n", $output));
    $duration = null;
    foreach ($ffmpegResult->streams as $stream) {
        $curDuration = floor(floatval($stream->duration) * 1000);
        if (is_null($duration) || $curDuration < $duration) {
            $duration = $curDuration;
        }
    }
    // store to cache
    apc_store($cacheKey, $duration);
    return $duration;
}
コード例 #18
0
function ApcCheckIp($installer)
{
    $ok = true;
    $ip = $_SERVER["REMOTE_ADDR"];
    if (isset($ip) && strlen($ip)) {
        $now = time();
        $key = "inst-ip-{$ip}-{$installer}";
        $history = apc_fetch($key);
        if (!$history) {
            $history = array();
        } elseif (!is_array($history)) {
            $history = json_decode($history, true);
            if (!$history) {
                $history = array();
            }
        }
        $history[] = $now;
        // Use 1KB blocks to prevent fragmentation
        apc_store($key, str_pad(json_encode($history), 1000), 604800);
        if (count($history) > 10) {
            array_shift($history);
        }
        $count = 0;
        foreach ($history as $time) {
            if ($now - $time < 3600) {
                $count++;
            }
        }
        if ($count > 4) {
            $ok = false;
        }
    }
    return $ok;
}
コード例 #19
0
 /**
  * Save values for a set of keys to cache
  *
  * @param  array   $keys   list of values to save
  * @param  int     $expire expiration time
  * @return boolean true on success, false on failure
  */
 protected function write(array $keys, $expire = null)
 {
     foreach ($keys as $k => $v) {
         apc_store($k, $v, $expire);
     }
     return true;
 }
コード例 #20
0
ファイル: ApcCache.php プロジェクト: dw250100785/b8framework
 /**
  * Add an item to the cache:
  */
 public function set($key, $value = null, $ttl = 0)
 {
     if (!self::isEnabled()) {
         return false;
     }
     return apc_store($this->cachePrefix . $key, $value, $ttl);
 }
コード例 #21
0
ファイル: APCClient.php プロジェクト: beryllium/cache
 /**
  * Add a value to the cache under a unique key
  *
  * @param string $key Unique key to identify the data
  * @param mixed $value Data to store in the cache
  * @param int $ttl Lifetime for stored data (in seconds)
  * @return boolean
  */
 public function set($key, $value, $ttl)
 {
     if (!$this->safe) {
         return false;
     }
     return apc_store($key, $value, $ttl);
 }
コード例 #22
0
ファイル: CacheApc.php プロジェクト: dalinhuang/shopexts
 public function set($key, $value)
 {
     // we store it with the cache_time default expiration so objects will atleast get cleaned eventually.
     if (@apc_store($key, array('time' => time(), 'data' => serialize($value)), Config::Get('cache_time')) == false) {
         throw new CacheException("Couldn't store data in cache");
     }
 }
コード例 #23
0
ファイル: cache.php プロジェクト: joshjim27/jobsglobal
 /**
  * STore the cache
  */
 public function store($data, $id, $group = null)
 {
     if (!$this->_caching) {
         return;
     }
     $cacheid = $this->_getCacheId($id);
     if (!is_null($group)) {
         // Store the id list in the group list
         $tags = apc_fetch('jomsocial-tags');
         // If tags is missing, the whole cache might be invalid, clear it all
         if (!is_array($tags)) {
             apc_clear_cache('user');
             $tags = array();
         }
         foreach ($group as $tag) {
             if (!isset($tags[$tag])) {
                 $tags[$tag] = array();
             }
             if (!in_array($cacheid, $tags[$tag])) {
                 $tags[$tag][] = $cacheid;
             }
         }
         // Store this key back
         apc_store('jomsocial-tags', $tags, 0);
     }
     // Do not use any group
     return apc_store($cacheid, $data);
 }
コード例 #24
0
ファイル: Apc.php プロジェクト: hdragomir/SmartStudent
 public function set($id, $data, array $tags = NULL, $lifetime)
 {
     if (!empty($tags)) {
         Kohana::log('error', 'Cache: tags are unsupported by the APC driver');
     }
     return apc_store($id, $data, $lifetime);
 }
コード例 #25
0
 /**
  * Set cache
  *
  * @param string $key
  * @param mixed $value
  * @param int $ttl
  * @return boolean
  */
 public function set($key, $value, $ttl = null)
 {
     if (null === $ttl) {
         $ttl = $this->_options['ttl'];
     }
     return apc_store($key, $value, $ttl);
 }
コード例 #26
0
ファイル: JBCacheAPC.php プロジェクト: vinothtimes/dchqtest
 function set($key, $data, $expire = false)
 {
     if (!$expire) {
         $expire = 0;
     }
     return apc_store($key, $data, $expire);
 }
コード例 #27
0
ファイル: Apc.php プロジェクト: raz0rsdge/horde
 /**
  */
 public function set($key, $data, $lifetime = 0)
 {
     $key = $this->_params['prefix'] . $key;
     if (apc_store($key . '_expire', time(), $lifetime)) {
         apc_store($key, $data, $lifetime);
     }
 }
コード例 #28
0
 /**
  * Logs the number of milliseconds till this named point.
  */
 public static function profile($point)
 {
     if (!self::$profilingEnabled) {
         return;
     }
     $path = "";
     if (isset($_SERVER['REQUEST_URI'])) {
         $path = $_SERVER['REQUEST_URI'];
     }
     if (strpos($path, 'af_format=json') !== false) {
         $memory = apc_fetch('Console::memory');
         if ($memory !== false) {
             list(self::$startedAt, self::$last) = $memory;
         }
     }
     $now = microtime(true);
     if (self::$startedAt === null) {
         self::$startedAt = $now;
         self::$last = $now;
     }
     $totalMillis = ($now - self::$startedAt) * 1000;
     $passedMillis = ($now - self::$last) * 1000;
     file_put_contents('php://stderr', self::formatPoint($totalMillis, $passedMillis, $point, $path));
     self::$last = $now;
     apc_store('Console::memory', array(self::$startedAt, self::$last));
 }
コード例 #29
0
ファイル: Apc_d.class.php プロジェクト: BPing/PHPCbping
 public function update($arg_key, $arg_value, $arg_expire = null)
 {
     if (apc_exists($arg_key)) {
         return apc_store($arg_key, $arg_value);
     }
     return false;
 }
コード例 #30
-1
ファイル: index.php プロジェクト: kordianbruck/TUM.sexy
function pdfToString()
{
    $weekNumber = date('W');
    //Check if we have the current week in cache
    $text = apc_fetch('hungertext' . $weekNumber);
    if ($text !== false) {
        return $text;
    }
    //Otherwise fetch all links
    $links = crawl_page(URL_PAGE_WITH_LINKS);
    $pdfLink = '';
    foreach ($links as $file) {
        if (strpos(strtolower($file), '.pdf') !== FALSE && strpos($file, '_FMI_') !== FALSE && $weekNumber === substr($file, 16, 2)) {
            $pdfLink = URL_MAIN . $file;
        }
    }
    //Don't proceed when no link was found
    if (empty($pdfLink)) {
        return;
    }
    // Parse pdf file and build necessary objects.
    $parser = new \Smalot\PdfParser\Parser();
    $pdf = $parser->parseFile($pdfLink);
    $text = $pdf->getText();
    //Store it in cache
    apc_store('hungertext' . $weekNumber, $text, 2 * 24 * 3600);
    //return it
    return $text;
}