/** * 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); }
/** * @see Cache::_set() */ protected function _set($key, $value, $ttl = 0) { if (!$this->is_connected) { return false; } return $this->memcache->set($key, $value, 0, $ttl); }
/** * {@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); }
/** * @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; }
/** * @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']); }
/** * 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)); }
public function set($key, $value, $expire = '') { if (!$expire) { $expire = $this->config['expire']; } return $this->instance->set($key, $value, 0, $expire); }
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; }
/** * {@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); }
/** * 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); }
/** * @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); }
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)); }
/** * @inheritdoc */ public function setExpired($key, $value, $ttl) { if ($ttl > 2592000) { $ttl = 2592000; } $this->memcache->set($key, $value, $this->getCompressedFlag(), $ttl); }
/** * 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); } }
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); } }
/** * Attempt to save a key value pair to memcache. * * @param string $key index to use into memcache * @param mixed $value data to store for that index * @param int $expire * @return bool */ public function set($key, $value, $expire = 0) { if ($this->open()) { $compress = is_scalar($value) ? null : $this->compress; return $this->memcache->set($key, $value, $compress, $expire); } return false; }
public function set($id, $value, $ttl = null) { $ttl = $ttl ?: 0; if ($ttl > 0) { $ttl = time() + $ttl; } return $this->memcache->set($id, $value, 0, $ttl); }
/** * Save values for a set of keys to cache. * * @param array $keys list of values to save * @param int $expire expiration time * * @return bool true on success, false on failure */ protected function write(array $keys, $expire = null) { foreach ($keys as $k => $v) { $k = sha1($k); $this->memcache->set($k, $v, 0, $expire); } return true; }
/** * @param string $key * @param \DateTime $time * * @return bool */ public function set($key, \DateTime $time) { $key = $this->prefix . $key; if (!($old_time = $this->memcache->get($key)) || $old_time < $time->getTimestamp()) { return $this->memcache->set($key, $time->getTimestamp()); } return true; }
public function set($id, $data, $expire = 0, $compressed = false) { /* if($_SERVER['HTTP_HOST']=='localhost') return; */ if ($compressed) { return $this->_memcache->set($this->cache_name . $id, $data, MEMCACHE_COMPRESSED, $expire); } else { return $this->_memcache->set($this->cache_name . $id, $data, 0, $expire); } }
/** * Put an object in memcache. if there's already an entry * with the specified key it will be overwritten * * @param string $key * @param mixed $value * @param int $expire the number of seconds after which cached item expires * @param int $flag * @return bool ture if successful false otherwise */ public function set($key, $value, $expire = 0, $flag = 0) { if (empty($key)) { throw new InvalidArgumentException("\$key can't be empty"); } if (!$this->memcache->set($key, $value, $flag, $expire)) { throw new RuntimeException("Unable to set data to Memcache"); } }
/** * Store data to memcached server. Return false if no Memcache is available. * * @param string $key * @param mixed $value * @return boolean|\HealthCareAbroad\MemcacheBundle\Services\MemcacheService */ public function set($key, $value, $expire = null) { if (!$this->hasMemcache) { return false; } // save the value to memcache $this->memcache->set($key, $value, null, $expire); return true; }
/** * Save values for a set of keys to cache * * @param array $keys list of values to save * @param int $expire expiration time * @return boolean true on success, false on failure */ protected function write(array $keys, $expire = null) { foreach ($keys as $k => $v) { $k = sha1($k); //$v = serialize($v); $this->phpFastCache->set($k, $v, $expire); } return true; }
/** * @param string $key * @param mixed $value */ public function set($key, $value) { if (isset($this->options['memcache.timelive'])) { $timeLive = $this->options['memcache.timelive']; } else { $timeLive = 3600; } $this->client->set($key, $value, $this->options); }
/** * {@inheritdoc } */ public function set($key, $value, $ttl = null) { $tKey = $this->getKey($key); $tValue = $this->serialize($value); if (!$ttl) { $ttl = $this->ttl; } $this->server->set($tKey, $tValue, false, time() + $ttl); }
public function store($key, $value, $timeout = null) { if ($timeout === null) { $timeout = (int) ini_get("session.gc_maxlifetime"); } elseif (!is_numeric($timeout) || $timeout < 1) { $message = __METHOD__ . "() invalid timeout value."; throw new Sabel_Exception_InvalidArgument($message); } $this->memcache->set($this->getKey($key), $value, false, $timeout); }
/** * {@inheritdoc} */ public function put($key, $data, $ttl = 0) { if ($ttl !== 0) { $ttl += time(); } if ($this->memcache->replace($key, $data, $this->compressionLevel, $ttl) === false) { return $this->memcache->set($key, $data, $this->compressionLevel, $ttl); } return true; }
/** * 设置缓存 * * @param string $key 要设置的缓存项目名称 * @param mixed $value 要设置的缓存项目内容 * @param int $time 要设置的缓存项目的过期时长,默认保存时间为 -1,永久保存为 0 * * @return bool 保存是成功为true ,失败为false */ public function store($key, $value, $time = -1) { if ($time == -1) { $time = $this->expire; } $sValue = serialize($value); if (!$this->connection->add($key, $sValue, $this->compressed, $time)) { return $this->connection->set($key, $sValue, $this->compressed, $time); } return true; }
/** * @see \Kalibri\Cache\BaseInterface::set(); */ public function set($key, $value, $expire = 0) { if (\Kalibri::config()->get('debug.log.is-enabled', false)) { \Kalibri::logger()->add(\Kalibri\Logger\Base::L_DEBUG, "SET: (ttl={$expire}) {$key}=" . var_export($value, true), $this); } if (!$this->_memcache->replace($key, $value, MEMCACHE_COMPRESSED, $expire)) { $this->_memcache->set($key, $value, MEMCACHE_COMPRESSED, $expire); } $this->_local[$key] = $value; return $this; }
public function set($key, $value, $ttl) { if (null === $this->memcache) { $this->connect(); } $result = $this->memcache->set($key, $value, 0, $ttl); if (!$result) { throw new Exception('Set failed', Exception::SET_FAILED); } return $result; }