当前位置: 首页>>代码示例>>PHP>>正文


PHP apcu_store函数代码示例

本文整理汇总了PHP中apcu_store函数的典型用法代码示例。如果您正苦于以下问题:PHP apcu_store函数的具体用法?PHP apcu_store怎么用?PHP apcu_store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了apcu_store函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set

 public function set($key, $value, $ttl)
 {
     if (is_array($key)) {
         apcu_store($key, null, $ttl);
     } else {
         apcu_store($key, $value, $ttl);
     }
 }
开发者ID:xiaoniainiu,项目名称:php-yaf-yk,代码行数:8,代码来源:cache.php

示例2: storeItemInCache

 protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
 {
     if ($ttl < 0) {
         return false;
     }
     return apcu_store($key, $item->get(), $ttl);
 }
开发者ID:aequasi,项目名称:cache-1,代码行数:7,代码来源:ApcuCachePool.php

示例3: set

 /**
  * Set a value to cache with id and lifetime
  *
  *     $data = 'bar';
  *
  *     // Set 'bar' to 'foo' in apc group, using default expiry
  *     Cache::instance('apc')->set('foo', $data);
  *
  *     // Set 'bar' to 'foo' in apc group for 30 seconds
  *     Cache::instance('apc')->set('foo', $data, 30);
  *
  * @param   string $id id of cache entry
  * @param   string $data data to set to cache
  * @param   integer $lifetime lifetime in seconds
  * @return  boolean
  */
 public function set($id, $data, $lifetime = NULL)
 {
     if ($lifetime === NULL) {
         $lifetime = $this->default_expire;
     }
     return \apcu_store($this->_sanitize_id($id), $data, $lifetime);
 }
开发者ID:levmorozov,项目名称:mii,代码行数:23,代码来源:Apcu.php

示例4: save

 public function save($objectId, $object, $expiration = null)
 {
     $value = apcu_store($this->encode($this->apcNameSpace(), $objectId), $object, $expiration === null ? $this->expire() : $expiration);
     if ($value === false) {
         throw new WURFL_Storage_Exception("Error saving variable in APC cache. Cache may be full.");
     }
 }
开发者ID:acasademont,项目名称:wurfl,代码行数:7,代码来源:Apcu.php

示例5: store

 public function store($key, $value)
 {
     if (apcu_store($key, $value)) {
         apcu_inc('__known_apcu_size', strlen($value));
     }
     return false;
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:7,代码来源:APCuCache.php

示例6: strongAdd

 public function strongAdd(string $key, string $value, int $life = 3600) : bool
 {
     if ($life == 0) {
         $life = null;
     }
     return apcu_store($key, $value, $life);
 }
开发者ID:knowsee,项目名称:uoke_framework,代码行数:7,代码来源:apcu.class.php

示例7: cacheStore

 /**
  * @param string $key
  * @param mixed $item
  * @return bool
  */
 protected static function cacheStore($key, $item)
 {
     if (self::apcuExists()) {
         return apcu_store($key, $item);
     }
     return false;
 }
开发者ID:powerlinks,项目名称:php-open-rtb,代码行数:12,代码来源:Cache.php

示例8: test_purge

 /**
  * Test purging the apcu cache store.
  */
 public function test_purge()
 {
     if (!cachestore_apcu::are_requirements_met()) {
         $this->markTestSkipped('Could not test cachestore_apcu. Requirements are not met.');
     }
     $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_apcu', 'phpunit_test');
     $instance = cachestore_apcu::initialise_unit_test_instance($definition);
     // Test a simple purge return.
     $this->assertTrue($instance->purge());
     // Test purge works.
     $this->assertTrue($instance->set('test', 'monster'));
     $this->assertSame('monster', $instance->get('test'));
     $this->assertTrue($instance->purge());
     $this->assertFalse($instance->get('test'));
     // Test purge with custom data.
     $this->assertTrue($instance->set('test', 'monster'));
     $this->assertSame('monster', $instance->get('test'));
     $this->assertTrue(apcu_store('test', 'pirate', 180));
     $this->assertSame('monster', $instance->get('test'));
     $this->assertTrue(apcu_exists('test'));
     $this->assertSame('pirate', apcu_fetch('test'));
     // Purge and check that our data is gone but the the custom data is still there.
     $this->assertTrue($instance->purge());
     $this->assertFalse($instance->get('test'));
     $this->assertTrue(apcu_exists('test'));
     $this->assertSame('pirate', apcu_fetch('test'));
 }
开发者ID:linnaea,项目名称:moodle-cachestore_apcu,代码行数:30,代码来源:apcu_test.php

示例9: apc_store

 /**
  * apcu library 5.x for php 7 have no more functions apc_*
  * Uses apcu_* instead
  */
 public static function apc_store($key, $var, $ttl)
 {
     if (self::isPhp7()) {
         return apcu_store($key, $var, $ttl);
     } else {
         return apc_store($key, $var, $ttl);
     }
 }
开发者ID:kojoty,项目名称:opencaching-pl,代码行数:12,代码来源:Php7Handler.php

示例10: store

 /**
  * Store the value in the apc memory
  *
  * @false string $key
  * @false mix $value
  * @param $key
  * @param $value
  * @throws \Exception
  * @return bool
  */
 public function store($key, $value, $minute = null)
 {
     if (is_null($key) || $key == "") {
         throw new \InvalidArgumentException("Key shouldn't be empty");
     }
     $time = is_null($minute) ? $this->getLifeTime() : $minute * 60;
     return $this->isApcUEnabled ? apcu_store($key, $value, $time) : apc_store($key, $value, $time);
 }
开发者ID:jhonbendar,项目名称:framework,代码行数:18,代码来源:Apc.php

示例11: testAPCUIterator

 public function testAPCUIterator()
 {
     $key = __CLASS__;
     $this->assertTrue(apcu_store($key, 456));
     $entries = iterator_to_array(new \APCUIterator('/^' . preg_quote($key, '/') . '$/', APC_ITER_KEY | APC_ITER_VALUE));
     $this->assertSame(array($key), array_keys($entries));
     $this->assertSame($key, $entries[$key]['key']);
     $this->assertSame(456, $entries[$key]['value']);
 }
开发者ID:derrabus,项目名称:polyfill,代码行数:9,代码来源:ApcuTest.php

示例12: put

 /**
  * Put a key/value set in the cache.
  * @see apc_store()
  *
  * @param mixed   $key
  * @param mixed   $value
  * @param integer $ttl   (in seconds)
  *
  * @return boolean
  */
 public function put($key, $value, $ttl = 0)
 {
     if (function_exists('apcu_store')) {
         return apcu_store($key, $value, $ttl);
     } elseif (function_exists('apc_store')) {
         return apc_store($key, $value, $ttl);
     }
     return false;
 }
开发者ID:dan-lyn,项目名称:apcwrapper,代码行数:19,代码来源:ApcWrapper.php

示例13: store

 public static function store($k, $v, $ttl = 300)
 {
     if (function_exists('apc_store')) {
         return apc_store($k, $v, $ttl);
     } elseif (function_exists('apcu_store')) {
         return apcu_store($k, $v, $ttl);
     }
     return false;
 }
开发者ID:netroby,项目名称:crossapc,代码行数:9,代码来源:crossapc.php

示例14: set

 public function set($name, $value, $ttl = 0)
 {
     if ($this->hasAPCu) {
         apcu_store($name, $value, $ttl);
     } else {
         $_SESSION[$name] = $value;
     }
     return true;
 }
开发者ID:xuedi,项目名称:pedetes,代码行数:9,代码来源:cache.php

示例15: setDataStore

 public function setDataStore($key, $data, $timeCache = null)
 {
     if (!empty($timeCache)) {
         apcu_store($key, $data, $timeCache);
     } else {
         apcu_store($key, $data, $this->timeCache);
     }
     return true;
 }
开发者ID:drivesoftz,项目名称:post-app-basic,代码行数:9,代码来源:APCCache.php


注:本文中的apcu_store函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。