public function increment($k, $step = 1) { if ($this->core) { return $this->core->increment($k, $step); } return apc_inc($k, $step); }
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); } } }
/** * 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); } }
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']); }
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); }
public function increaseSaves($key) { $key .= 'inc'; if (!$this->load($key)) { $this->save($key, 0); } return apc_inc($key, 1); }
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; }
/** * 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); }
/** * 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); }
/** * 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; }
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; }
/** * @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); }
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); } }
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); }
/** * 获取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; }
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; }
/** * 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; }
/** * 递增 * 与原始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; } }
/** * 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; }
/** * 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; }
public function inc($key, $step = 1) { $this->type = $type; return apc_inc($this->_key($key), $step) !== false ? apc_fetch($this->_key($key)) : false; }
<?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;
public function incr($key, $value = 1) { return apc_inc($key . self::KEY_SUFFIX, $value); }
// 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) {
/** * 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); }
public function inc($key, $interval = 1) { return apc_inc($this->_p($key), $interval); }
function apcu_inc($key, $step = 1, &$success = false) { return apc_inc($key, $step, $success); }
/** * 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; }
/** * 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); }