本文整理汇总了PHP中Memcache::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::set方法的具体用法?PHP Memcache::set怎么用?PHP Memcache::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcache
的用法示例。
在下文中一共展示了Memcache::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update a part of a document
*
* @return array
* @param array $partialDocument
* @param mixed $id
* @param array $options
*/
public function update($partialDocument, $id, $options = array())
{
$document = json_encode(array('doc' => $partialDocument));
$url = $this->buildUrl(array($this->type, $id));
$response = $this->conn->set($url, $document);
return array('ok' => $response);
}
示例2: _set
/**
* @see Cache::_set()
*/
protected function _set($key, $value, $ttl = 0)
{
if (!$this->is_connected) {
return false;
}
return $this->memcache->set($key, $value, 0, $ttl);
}
示例3: set
/**
* {@inheritdoc}
*/
public function set($key, $value, $ttl = null)
{
if (!$ttl) {
$ttl = $this->ttl;
}
$this->server->set($this->getKey($key), $this->pack($value), false, time() + $ttl);
}
示例4: set
/**
* @param mixed $data Data to put in cache
* @param string $id Cache id
* @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @throws App_Cache_Memcached_Exception
* @return boolean True if no problem
*/
public function set($id, $data, $specificLifetime = false, $tags = array())
{
if (!$data) {
return false;
}
if (!$id) {
throw new App_Cache_Memcached_Exception('ID can`t be NULL');
}
self::_validateIdOrTag($id);
$lifetime = $this->getLifetime($specificLifetime);
if ($tags) {
$cols = 'cache_id,tag';
$values = [];
$db = $this->_options['db'];
$sqlId = $db->quote($id);
foreach ($tags as $tag) {
$values[] = '(' . $sqlId . ',' . $db->quote($tag) . ')';
}
$sql = "INSERT IGNORE INTO " . $db->quoteIdentifier($this->_options['tagsTableName'], true) . ' (' . $cols . ') ' . 'VALUES ' . implode(', ', $values);
$db->query($sql);
}
$result = $this->_memcached->set($id, $data, $lifetime);
if (!$result) {
$this->remove($id, true);
return false;
}
return true;
}
示例5: set
/**
* @see ICache::set()
*/
public function set($key, $content, $expire = null)
{
if ($expire !== null) {
$this->configs['expire'] = $expire;
}
return self::$Mem->set($key, $content, MEMCACHE_COMPRESSED, $this->configs['expire']);
}
示例6: set
/**
* Set a value in the cache
*
* @param string $p_sKey The Key
* @param mixed $p_mData The Data
* @param integer $p_mTTL The Time To Live
* @return boolean
*/
function set($p_sKey, $p_mData, $p_mTTL = 0)
{
if ($this->_serverAdded === false) {
$this->addServer('localhost');
}
return $this->_handler->set($p_sKey, $p_mData, is_numeric($p_mTTL) ? $p_mTTL : strtotime($p_mTTL));
}
示例7: set
public function set($key, $value, $expire = '')
{
if (!$expire) {
$expire = $this->config['expire'];
}
return $this->instance->set($key, $value, 0, $expire);
}
示例8: checkCache
function checkCache($check = 0, $in, $out, $set = 0)
{
$inOut = 'inOut_' . $in . '_' . $out;
$memcache_obj = new Memcache();
$memcache_obj->connect('127.0.0.1', 11211) or die("Could not connect");
if ($check === 1) {
$available = $memcache_obj->get($inOut);
if (!$available) {
$set = $this->superfastCheck(1, $in, $out);
$memcache_obj->set($inOut, $set, false, 324);
$available = $memcache_obj->get($inOut);
}
} elseif ($check === 2) {
$memcache_obj->flush();
} else {
$set = $this->superfastCheck($in, $out);
//var_dump($set);
$memcache_obj->set($inOut, $set, false, 324);
//echo $inOut;
$available = $memcache_obj->get($inOut);
//var_dump($memcache_obj->getStats());
}
//var_dump($available);
$memcache_obj->close();
return $available;
}
示例9: set
/**
* {@inheritDoc}
*/
public function set($key, $value, $timeout = null)
{
if (is_null($timeout)) {
$timeout = static::DEFAULT_TIMEOUT;
}
return $this->memcache->set($key, $value, MEMCACHE_COMPRESSED, $timeout);
}
示例10: _updateValue
/**
* Write a line to the logfile.
* @param String $line
*/
protected function _updateValue($message, $keyPostfix = "")
{
$key = $this->_getKey($keyPostfix);
$value = $this->_memcache->get($key);
$value .= self::VALUE_SEPARATOR . $message;
$this->_memcache->set($key, $value, null, $this->_expiry);
}
示例11: put
/**
* @inheritdoc
*/
public function put($key, $value, $ttl = 0)
{
if ($ttl > 30 * 24 * 3600) {
$ttl = time() + $ttl;
}
return $this->memcache->set($key, $value, 0, (int) $ttl);
}
示例12: set
public function set($key, $value, $ttl = null)
{
if (is_resource($value)) {
return false;
}
return true === $this->memcache->set(self::normalizeKey($key), $value, 0, self::normalizeTtl($ttl));
}
示例13: setExpired
/**
* @inheritdoc
*/
public function setExpired($key, $value, $ttl)
{
if ($ttl > 2592000) {
$ttl = 2592000;
}
$this->memcache->set($key, $value, $this->getCompressedFlag(), $ttl);
}
示例14: set
/**
* Adds a cache with an unique Id.
*
* @param string $id Cache Id
* @param mixed $data Data to be stored
* @param int $expire Seconds to expired
* @param int $compressed To store the data in Zlib compressed format
* @return bool True if success
*/
public function set($id, $data, $expire = 0, $compressed = false)
{
if ($compressed) {
return $this->_memcache->set($id, $data, MEMCACHE_COMPRESSED, $expire);
} else {
return $this->_memcache->set($id, $data, 0, $expire);
}
}
示例15: write
public function write($id, $data)
{
if ($this->injectors['lifetime']) {
return $this->redis->setex(strtr($this->injectors['name'], array(':id' => $id)), $this->injectors['lifetime'], $data);
} else {
return $this->redis->set(strtr($this->injectors['name'], array(':id' => $id)), $data);
}
}