예제 #1
0
파일: Apc.php 프로젝트: wukka/store
 public function increment($k, $step = 1)
 {
     if ($this->core) {
         return $this->core->increment($k, $step);
     }
     return apc_inc($k, $step);
 }
예제 #2
0
function setup()
{
    $i = apc_inc('foo', 1);
    var_dump($i);
    $text = "";
    for ($t = 0; $t < $i; $t++) {
        // define a number of classes that should use
        // the same amount of memory as X, so that X will
        // be allocated at a different address on each request
        $text .= "class X{$t} extends Y { function bar() {} }\n";
    }
    $text .= "class Y { const C = {$i}; }\n";
    $file = __FILE__ . ".inc";
    file_put_contents($file, "<?php {$text}");
    include $file;
    unlink($file);
    class X extends Y
    {
        private $priv = 42;
        function foo()
        {
            var_dump($this->priv + self::C);
        }
    }
}
예제 #3
0
 /**
  * Increments counter value for the given bucket
  *
  * @param string $commandKey
  * @param string $type
  * @param integer $index
  */
 public function incrementBucket($commandKey, $type, $index)
 {
     $bucketName = $this->prefix($commandKey . '_' . $type . '_' . $index);
     if (!apc_add($bucketName, 1, self::BUCKET_EXPIRE_SECONDS)) {
         apc_inc($bucketName);
     }
 }
예제 #4
0
 public function updateCounter(array $data)
 {
     $new = apc_add($this->valueKey($data), 0);
     if ($new) {
         apc_store($this->metaKey($data), json_encode($this->metaData($data)));
     }
     apc_inc($this->valueKey($data), $data['value']);
 }
예제 #5
0
파일: Apc.php 프로젝트: rickysu/tagcache
 public function inc($key, $expire = 0)
 {
     $key = $this->buildKey($key);
     if (apc_inc($key) === false) {
         return apc_store($key, 1, $expire);
     }
     return true;
 }
 /**
  * {@inheritDoc}
  */
 public function get($timestamp)
 {
     $key = sprintf('apc_inc_%d', $timestamp);
     if (apc_add($key, 0, $this->ttl)) {
         return 0;
     }
     return apc_inc($key);
 }
예제 #7
0
 public function increaseSaves($key)
 {
     $key .= 'inc';
     if (!$this->load($key)) {
         $this->save($key, 0);
     }
     return apc_inc($key, 1);
 }
예제 #8
0
파일: cache.apc.php 프로젝트: my1977/shopnc
 public function inc($key, $step = 1)
 {
     $this->type = $type;
     if (apc_inc($this->_key($key), $step) !== FALSE) {
         return apc_fetch($this->_key($key));
     }
     return FALSE;
 }
예제 #9
0
 /**
  * Assigns a value to the specified offset.
  *
  * @param mixed $offset The offset to assign the value to
  * @param mixed $value  The value to set
  *
  * @return void
  * @see \ArrayAccess::offsetSet()
  * @link http://php.net/manual/en/arrayaccess.offsetset.php
  */
 public function offsetSet($offset, $value)
 {
     // add the data depending an offset has been passed or not
     if (is_null($offset)) {
         $offset = apc_inc($this->serial);
     }
     // store the data back to the property
     $this->__set($offset, $value);
 }
예제 #10
0
 /**
  * Increases the value in the variable store
  * @param string $key The key of the variable
  * @param integer $value The value to increase with
  * @param integer $timeToLive Set to a number of seconds to make the variable expire in that amount of time
  * @return mixed The new value of the variable
  */
 public function increase($key, $value = null, $timeToLive = null)
 {
     if ($value === null) {
         $value = 1;
     }
     // make sure the variable exists
     apc_add($key, 0);
     return apc_inc($key, $value);
 }
예제 #11
0
파일: APC.php 프로젝트: hypnomez/opir.org
 /**
  * Delete item from cache
  *
  * @param string	$item	May contain "/" symbols for cache structure, for example users/<i>user_id</i>
  *
  * @return bool
  */
 function del($item)
 {
     if (!$this->apc) {
         return false;
     }
     apc_delete($this->namespaces_imitation($item));
     apc_inc('/' . DOMAIN . "/{$item}");
     unset($this->root_versions_cache['/' . DOMAIN . "/{$item}"]);
     return true;
 }
예제 #12
0
파일: APC.php 프로젝트: hharrysidhu/OpenVBX
 protected function _invalidate($group, $tenant_id)
 {
     $_ggroup = $this->_generation_keyname($group, $tenant_id);
     $generation = apc_inc($_ggroup, 1, $success);
     if (!$success) {
         apc_store($_ggroup, 0);
         $generation = 0;
     }
     return $generation;
 }
예제 #13
0
파일: APC.php 프로젝트: romeoz/rock-cache
 /**
  * @inheritdoc
  */
 public function increment($key, $offset = 1, $expire = 0, $create = true)
 {
     $hash = $this->prepareKey($key);
     if ($this->exists($key) === false) {
         if ($create === false) {
             return false;
         }
         apc_add($hash, 0, $expire);
     }
     return apc_inc($hash, $offset);
 }
예제 #14
0
 public function increment($name, $value = 1)
 {
     static $prefix;
     if (!isset($prefix)) {
         $prefix = Kwf_Cache_Simple::getUniquePrefix() . 'bench-';
     }
     apc_inc($prefix . $name, $value, $success);
     if (!$success) {
         apc_add($prefix . $name, $value);
     }
 }
예제 #15
0
 public function testAPC()
 {
     $key = 'APCPolyfillTest';
     apc_store($key, 1);
     apc_inc($key, 2);
     apc_dec($key);
     $this->assertEquals(apc_fetch($key, $success), 2);
     $this->assertTrue($success);
     apc_delete($key);
     apc_fetch($key, $success);
     $this->assertFalse($success);
 }
예제 #16
0
파일: Visit.php 프로젝트: JudonH/writer
 /**
  * 获取apc缓存
  */
 private function _apc()
 {
     if (!function_exists('apc_inc')) {
         //apc可用
         return 0;
     }
     $ret = apc_inc($this->_key);
     if (!$ret) {
         apc_store($this->_key, 1, $this->_interval);
         $ret = 1;
     }
     return $ret;
 }
예제 #17
0
 public function dispatch($path)
 {
     $key = $this->getNamespace() . ':' . $path;
     if (($route = apc_fetch($key)) !== false) {
         apc_inc('hits:' . $key);
         // record the hits
         return $route;
     }
     if ($route = $this->mux->dispatch($path)) {
         apc_store($key, $route, $this->expiry);
         return $route;
     }
     apc_store($key, false, $this->expiry);
     return false;
 }
예제 #18
0
 /**
  * increments a APC counter
  */
 public function increment($key, $step = 1, $expire)
 {
     $key = $this->cacheKey($key);
     // try to increment a already existing counter
     $val = apc_inc($key, $step, $success);
     self::$requestStats['set']++;
     // counter seems not to be existing
     if (!$success) {
         // init the counter using add() to circumvent race conditions
         apc_add($key, 0, $this->calcTtl($expire));
         self::$requestStats['set']++;
         // increment again after counter creation
         $val = apc_inc($key, $step, $success);
         self::$requestStats['set']++;
     }
     if ($success) {
         return $val;
     }
     return false;
 }
예제 #19
0
 /**
  * 递增
  * 与原始increment方法区别的是若不存指定KEY时返回false,这个会自动递增
  *
  * @param string $key
  * @param int $offset
  * @param int $lifetime 当递减失则时当作set使用
  */
 public function increment($key, $offset = 1, $lifetime = 60)
 {
     if (\apc_inc($key, $offset)) {
         return true;
     } elseif (false == \apc_exists($key) && $this->set($key, $offset, $lifetime)) {
         return true;
     } else {
         return false;
     }
 }
예제 #20
0
파일: Apc.php 프로젝트: haoyanfei/zf2
 /**
  * Internal method to increment an item.
  *
  * @param  string $normalizedKey
  * @param  int    $value
  * @return int|boolean The new value on success, false on failure
  * @throws Exception\ExceptionInterface
  */
 protected function internalIncrementItem(&$normalizedKey, &$value)
 {
     $options = $this->getOptions();
     $prefix = $options->getNamespace() . $options->getNamespaceSeparator();
     $internalKey = $prefix . $normalizedKey;
     $ttl = $options->getTtl();
     $value = (int) $value;
     $newValue = apc_inc($internalKey, $value);
     // initial value
     if ($newValue === false) {
         $ttl = $options->getTtl();
         $newValue = $value;
         if (!apc_add($internalKey, $newValue, $ttl)) {
             throw new Exception\RuntimeException("apc_add('{$internalKey}', {$newValue}, {$ttl}) failed");
         }
     }
     return $newValue;
 }
예제 #21
0
파일: apc.php 프로젝트: rhymix/rhymix
 /**
  * Increase the value of a key by $amount.
  * 
  * If the key does not exist, this method assumes that the current value is zero.
  * This method returns the new value.
  * 
  * @param string $key
  * @param int $amount
  * @return int
  */
 public function incr($key, $amount)
 {
     $result = apc_inc($key, $amount);
     if ($result === false) {
         apc_store($key, $amount);
         $result = $amount;
     }
     return $result;
 }
예제 #22
0
 public function inc($key, $step = 1)
 {
     $this->type = $type;
     return apc_inc($this->_key($key), $step) !== false ? apc_fetch($this->_key($key)) : false;
 }
예제 #23
0
파일: apc.php 프로젝트: myersguo/phpio
<?php

echo "Let's do something with success", PHP_EOL;
apc_store('anumber', 42);
echo apc_fetch('anumber'), PHP_EOL;
echo apc_inc('anumber'), PHP_EOL;
예제 #24
0
 public function incr($key, $value = 1)
 {
     return apc_inc($key . self::KEY_SUFFIX, $value);
 }
예제 #25
0
// Enable Cross-Origin Resource Sharing (CORS)
//////////////////////////////////
if ($options->cors) {
    header('Access-Control-Allow-Origin: *');
}
//////////////////////////////////
// Check for cached copy
//////////////////////////////////
if ($options->caching) {
    debug('Caching is enabled...');
    $cache_id = md5((int) $max . $url . $links . (int) $favour_feed_titles . (int) $options->content . (int) $options->summary . (int) $xss_filter . (int) $exclude_on_fail . $format . $detect_language);
    $check_cache = true;
    if ($options->apc === true && $options->smart_cache === true) {
        apc_add("cache.{$cache_id}", 0, isset($options->cache_ttl) ? $options->cache_ttl : 10 * 60);
        $apc_cache_hits = intval(apc_fetch("cache.{$cache_id}"));
        apc_inc("cache.{$cache_id}");
        if ($check_cache = $apc_cache_hits >= 2) {
            debug('Cache key found in APC, we\'ll try to load cache file from disk');
        } else {
            debug('Cache key not found in APC');
        }
    }
    if ($check_cache === true) {
        $cache = get_cache();
        if ($data = $cache->load($cache_id)) {
            if ($debug_mode) {
                debug('Loaded cached copy of RSS');
                exit;
            }
            if ($format == 'json') {
                if ($callback === null) {
예제 #26
0
파일: apc.php 프로젝트: Kevin-ZK/vaneDisk
 /**
  * Increase a stored number
  *
  * @param string $key
  * @param int $step
  * @return int | bool
  */
 public function inc($key, $step = 1)
 {
     $this->add($key, 0);
     return apc_inc($this->getPrefix() . $key, $step);
 }
예제 #27
0
파일: ham.php 프로젝트: radiosilence/ham
 public function inc($key, $interval = 1)
 {
     return apc_inc($this->_p($key), $interval);
 }
예제 #28
0
파일: bootstrap.php 프로젝트: raphydev/onep
 function apcu_inc($key, $step = 1, &$success = false)
 {
     return apc_inc($key, $step, $success);
 }
예제 #29
0
파일: ApcEngine.php 프로젝트: hupla78/Nadia
 /**
  * Increments the group value to simulate deletion of all keys under a group
  * old values will remain in storage until they expire.
  *
  * @param string $group The group to clear.
  * @return bool success
  */
 public function clearGroup($group)
 {
     apc_inc($this->settings['prefix'] . $group, 1, $success);
     return $success;
 }
예제 #30
0
 /**
  * Increment a raw value
  *
  * @param	string	$id	Cache ID
  * @param	int	$offset	Step/value to add
  * @return	mixed	New value on success or FALSE on failure
  */
 public function increment($id, $offset = 1)
 {
     return apc_inc($id, $offset);
 }