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


PHP Memcached::touch方法代码示例

本文整理汇总了PHP中Memcached::touch方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::touch方法的具体用法?PHP Memcached::touch怎么用?PHP Memcached::touch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memcached的用法示例。


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

示例1: touchKeys

 /**
  * renew caches
  * @param array $keys
  * @return bool
  */
 public function touchKeys($keys)
 {
     foreach ($keys as $key) {
         if (!$this->m->touch($key, 3600 * 24)) {
             return false;
         }
     }
     return true;
 }
开发者ID:gonejack,项目名称:tumblr-images-memcached,代码行数:14,代码来源:mc.php

示例2: write

 /**
  * Write
  *
  * Writes (create / update) session data
  *
  * @param	string	$session_id	Session ID
  * @param	string	$session_data	Serialized session data
  * @return	bool
  */
 public function write($session_id, $session_data)
 {
     if (!isset($this->_memcached)) {
         return $this->_fail();
     } elseif ($session_id !== $this->_session_id) {
         if (!$this->_release_lock() or !$this->_get_lock($session_id)) {
             return $this->_fail();
         }
         $this->_fingerprint = md5('');
         $this->_session_id = $session_id;
     }
     if (isset($this->_lock_key)) {
         $key = $this->_key_prefix . $session_id;
         $this->_memcached->replace($this->_lock_key, time(), 300);
         if ($this->_fingerprint !== ($fingerprint = md5($session_data))) {
             if ($this->_memcached->replace($key, $session_data, $this->_config['expiration']) or $this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration'])) {
                 $this->_fingerprint = $fingerprint;
                 return $this->_success;
             }
             return $this->_fail();
         }
         if ($this->_memcached->touch($key, $this->_config['expiration']) or $this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration'])) {
             return $this->_success;
         }
     }
     return $this->_fail();
 }
开发者ID:wpshang,项目名称:wps,代码行数:36,代码来源:Session_memcached_driver.php

示例3: touch

 /**
  * Sets a new expire time for an existing key
  *
  * @param string $cache_id
  * @param int $newexpiration
  * @return bool
  */
 public function touch($cache_id, $newexpiration = null)
 {
     if (is_null($newexpiration)) {
         return false;
     }
     return $this->memcache->touch($cache_id, $newexpiration);
 }
开发者ID:QRMarket,项目名称:PHP,代码行数:14,代码来源:CacheAbstract.class.php

示例4: touch

 /**
  * Touch a cache key (i.e., new expiration).
  *
  * @since 151216 Memcached utilities.
  *
  * @param string     $primary_key   Primary key.
  * @param string|int $sub_key       Sub-key to touch.
  * @param int        $expires_after Expires after (in seconds).
  *
  * @return bool True on success.
  */
 public function touch(string $primary_key, $sub_key, int $expires_after) : bool
 {
     if (!$this->Pool) {
         return false;
         // Not possible.
     }
     $time = time();
     $expires_after = max(0, $expires_after);
     $expires = $expires_after ? $time + $expires_after : 0;
     if (!($key = $this->key($primary_key, $sub_key))) {
         return false;
         // Fail; e.g., race condition.
     }
     return $this->Pool->touch($key, $expires);
 }
开发者ID:websharks,项目名称:core,代码行数:26,代码来源:Memcache.php

示例5: write

 /**
  * Write
  *
  * Writes (create / update) session data
  *
  * @param	string	$session_id	Session ID
  * @param	string	$session_data	Serialized session data
  * @return	bool
  */
 public function write($session_id, $session_data)
 {
     if (!isset($this->_memcached)) {
         return FALSE;
     } elseif ($session_id !== $this->_session_id) {
         /*			if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
         			{
         				return FALSE;
         			}*/
         $this->_fingerprint = md5('');
         $this->_session_id = $session_id;
     }
     /*		if (isset($this->_lock_key))
     		{
     			$this->_memcached->replace($this->_lock_key, time(), 300);
     			if ($this->_fingerprint !== ($fingerprint = md5($session_data)))
     			{
     				if ($this->_memcached->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration']))
     				{
     					$this->_fingerprint = $fingerprint;
     					return TRUE;
     				}
     
     				return FALSE;
     			}
     
     			return $this->_memcached->touch($this->_key_prefix.$session_id, $this->_config['expiration']);
     		}*/
     $this->_memcached->replace($this->_lock_key, time(), 300);
     if ($this->_fingerprint !== ($fingerprint = md5($session_data))) {
         if ($this->_memcached->set($this->_key_prefix . $session_id, $session_data, $this->_config['expiration'])) {
             $this->_fingerprint = $fingerprint;
             return TRUE;
         }
         return FALSE;
     }
     return $this->_memcached->touch($this->_key_prefix . $session_id, $this->_config['expiration']);
 }
开发者ID:shuai959980629,项目名称:TTDV1,代码行数:47,代码来源:Session_memcached_driver.php

示例6: write

 /**
  * Write
  *
  * Writes (create / update) session data
  *
  * @param    string $session_id   Session ID
  * @param    string $session_data Serialized session data
  *
  * @return    bool
  */
 public function write($session_id, $session_data)
 {
     if (!isset($this->memcached)) {
         return false;
     } elseif ($session_id !== $this->sessionID) {
         if (!$this->releaseLock() || !$this->lockSession($session_id)) {
             return false;
         }
         $this->fingerprint = md5('');
         $this->sessionID = $session_id;
     }
     if (isset($this->lockKey)) {
         $this->memcached->replace($this->lockKey, time(), 300);
         if ($this->fingerprint !== ($fingerprint = md5($session_data))) {
             if ($this->memcached->set($this->keyPrefix . $session_id, $session_data, $this->sessionExpiration)) {
                 $this->_fingerprint = $fingerprint;
                 return true;
             }
             return false;
         }
         return $this->memcached->touch($this->keyPrefix . $session_id, $this->sessionExpiration);
     }
     return false;
 }
开发者ID:titounnes,项目名称:CodeIgniter4,代码行数:34,代码来源:MemcachedHandler.php

示例7: testTouchSuccess

 public function testTouchSuccess()
 {
     $request = new MemcacheGetRequest();
     $request->addKey("key");
     $request->setForCas(true);
     $response = new MemcacheGetResponse();
     $item = $response->addItem();
     $item->setKey("key");
     $item->setValue("value");
     $item->setFlags(0);
     // string.
     $item->setCasId(123456);
     $this->apiProxyMock->expectCall('memcache', 'Get', $request, $response);
     $request = new MemcacheSetRequest();
     $item = $request->addItem();
     $item->setKey("key");
     $item->setValue("value");
     $item->setFlags(0);
     // string
     $item->setCasId(123456);
     $item->setSetPolicy(SetPolicy::CAS);
     $item->setExpirationTime(999);
     $response = new MemcacheSetResponse();
     $response->addSetStatus(SetStatusCode::STORED);
     $this->apiProxyMock->expectCall('memcache', 'Set', $request, $response);
     $memcached = new Memcached();
     $this->assertTrue($memcached->touch("key", 999));
     $this->apiProxyMock->verify();
 }
开发者ID:spudder-com,项目名称:spudder-django,代码行数:29,代码来源:MemcachedTest.php

示例8: Memcached

<?php

$m = new Memcached();
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$m->addServer('localhost', '11211');
$key = uniqid('touch_binary');
$m->set($key, 'test', time() + 86400);
$m->get($key);
echo "GET: " . $m->getResultMessage() . PHP_EOL;
$m->touch($key, time() + 86400);
echo "TOUCH: " . $m->getResultMessage() . PHP_EOL;
$m->touch($key, time() + 86400);
echo "TOUCH: " . $m->getResultMessage() . PHP_EOL;
$m->get($key);
echo "GET: " . $m->getResultMessage() . PHP_EOL;
$m->get($key);
echo "GET: " . $m->getResultMessage() . PHP_EOL;
echo "DONE" . PHP_EOL;
开发者ID:badlamer,项目名称:hhvm,代码行数:18,代码来源:touch-binary.php

示例9: changeTTL

 public function changeTTL($key, $exptime = 0)
 {
     return $this->client->touch($this->validateKeyEncoding($key), $this->fixExpiry($exptime));
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:4,代码来源:MemcachedBagOStuff.php

示例10: touch

 /**
  * @param $key
  * @param $expiration
  */
 public function touch($key, $expiration)
 {
     $this->memcached->touch($key, $expiration);
 }
开发者ID:nilportugues,项目名称:cache,代码行数:8,代码来源:Memcached.php

示例11: Memcached

<?php

$mc = new Memcached();
$mc->addServer('localhost', '11211');
$key = uniqid("this_does_not_exist_");
$mc->touch($key, 5);
var_dump($mc->getResultCode() == Memcached::RES_NOTFOUND);
$mc->set($key, 1, 5);
$mc->set($key, 1, 5);
var_dump($mc->getResultCode() == Memcached::RES_SUCCESS);
echo "OK\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:touch.php

示例12: touch

 /**
  * @inheritdoc
  */
 public function touch($key, $expire = 0)
 {
     return $this->storage->touch($this->prepareKey($key), $expire);
 }
开发者ID:romeoz,项目名称:rock-cache,代码行数:7,代码来源:Memcached.php

示例13: touch

 /**
  * @inheritdoc
  */
 public function touch($key, $expiration)
 {
     $key = $this->prefix . $key;
     return parent::touch($key, $expiration);
 }
开发者ID:jonafrank,项目名称:memcached-manager,代码行数:8,代码来源:MemcachedHandler.php

示例14: touch

 /**
  * Wrap the `touch()` method for php-memcached/libmemcached installations
  * that do not support it (< 1.7)
  *
  * @param string $key Key
  * @param integer $expriy Number of seconds until the item expires.
  * @return boolean Success or not.
  */
 function touch($key, $expriy = 0)
 {
     if (!method_exists("Memcached", "touch")) {
         trigger_error(E_WARNING, "Your memcached extension does not support the touch() method.");
         return false;
     }
     return parent::touch($key, $expiry);
 }
开发者ID:heweida,项目名称:php-couchbase-v2,代码行数:16,代码来源:Couchbase.php


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