本文整理汇总了PHP中apc_inc函数的典型用法代码示例。如果您正苦于以下问题:PHP apc_inc函数的具体用法?PHP apc_inc怎么用?PHP apc_inc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apc_inc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: increment
public function increment($k, $step = 1)
{
if ($this->core) {
return $this->core->increment($k, $step);
}
return apc_inc($k, $step);
}
示例2: setup
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: incrementBucket
/**
* 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: updateCounter
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: inc
public function inc($key, $expire = 0)
{
$key = $this->buildKey($key);
if (apc_inc($key) === false) {
return apc_store($key, 1, $expire);
}
return true;
}
示例6: get
/**
* {@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: increaseSaves
public function increaseSaves($key)
{
$key .= 'inc';
if (!$this->load($key)) {
$this->save($key, 0);
}
return apc_inc($key, 1);
}
示例8: inc
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: offsetSet
/**
* 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: increase
/**
* 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: del
/**
* 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: _invalidate
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: increment
/**
* @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: increment
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: testAPC
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);
}