本文整理汇总了PHP中Memcached::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::set方法的具体用法?PHP Memcached::set怎么用?PHP Memcached::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Store data on the cache server.
*
* @param string $key Key we can use to retrieve the data.
* @param string|array $data Data to store on the cache server.
* @param int $expiration Time before the data expires on the cache server.
*
* @return bool Success/Failure.
* @access public
*/
public function set($key, $data, $expiration)
{
if ($this->connected === true && $this->ping() === true) {
return $this->server->set($key, $this->isRedis ? $this->IgBinarySupport ? igbinary_serialize($data) : serialize($data) : $data, $expiration);
}
return false;
}
示例2: set
/**
* {@inheritdoc}
*/
public function set($key, $value, $ttl = null)
{
if (!$ttl) {
$ttl = $this->ttl;
}
$this->server->set($this->getKey($key), $this->pack($value), time() + $ttl);
}
示例3: save
/**
* save
*
* @param mixed $identifier identifier to save
* @param string $amount the current amount
* @param string $timespan the timespan in seconds
*
* @return boolean
*/
public function save($identifier = null, $amount = null, $timespan = null)
{
if (!$identifier && !$amount && !$timespan) {
throw new \InvalidArgumentException('identifier, amount and timespan are required');
}
return $this->memcached->set($this->fileName($identifier), $amount, $timespan);
}
示例4: _set
/**
* @see Cache::_set()
*/
protected function _set($key, $value, $ttl = 0)
{
if (!$this->is_connected) {
return false;
}
return $this->memcached->set($key, $value, $ttl);
}
示例5: set
/**
* @param string $key
* @param mixed $var
* @param int $expiration
* @return bool True on success, false on failure
*/
public function set($key, $var, $expiration = null)
{
if (!$this->memcached) {
throw new CacheException('No memcached defined.');
}
return $this->memcached->set($key, $var, $expiration === null ? 0 : $expiration);
}
示例6: set
/**
* Set a value against a key in the cache.
*
* @param string $key The key to store against
* @param string $value A json_encoded value
* @param int $expires Optional expiry time in seconds from now
*/
public function set($key, $value = null, $expires = 0)
{
if ($value === null) {
return $this->clear($key);
}
return $this->client->set($key, $value, $expires);
}
示例7: set
/**
* @param $key
* @param $data
* @return bool
*/
public function set($key, $data)
{
if (!is_null($this->memcache)) {
$this->memcache->set($key, $data, $this->expire);
}
return false;
}
示例8: 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));
}
示例9: setExpired
/**
* set cache-item by key => value + ttl
*
* @param string $key
* @param mixed $value
* @param int $ttl
*
* @return boolean
*/
public function setExpired($key, $value, $ttl)
{
if ($ttl > 2592000) {
$ttl = 2592000;
}
return $this->memcached->set($key, $value, $ttl);
}
示例10: put
/**
* @inheritdoc
*/
public function put($key, $value, $ttl = 0)
{
if ($ttl > 30 * 24 * 3600) {
$ttl = time() + $ttl;
}
return $this->memcached->set($key, $value, 0, (int) $ttl);
}
示例11: set
/**
* Store an item in the cache for a given number of minutes.
*
* @param string $key
* @param mixed $value
* @param int $seconds
* @param bool $strict
*
* @throws CacheSetException
*
* @return bool
*/
public function set($key, $value, $seconds, $strict = true)
{
$set = $this->memcached->set($key, $value, $seconds);
if (!$set && $strict) {
throw new CacheSetException($key);
}
}
示例12: Set
/**
* Sets an item into the cache
*
* @param string $key cache key
* @param mixed $value object to cache
* @param int $lifetime cached object lifetime
*/
public function Set($key, $value, $lifetime)
{
if (empty($key) || empty($value)) {
return;
}
$this->memcache->set($key, $value, false, time() + $lifetime);
}
示例13: set
public function set($id, $value, $ttl = null)
{
$ttl = $ttl ?: 0;
if ($ttl > 0) {
$ttl = time() + $ttl;
}
return $this->memcached->set($id, $value, $ttl);
}
示例14: set
public function set($key, $value, $ttl = 0)
{
if ($ttl > 0) {
return self::$cache->set($this->getNamespace() . $key, $value, $ttl);
} else {
return self::$cache->set($this->getNamespace() . $key, $value);
}
}
示例15: setUp
public function setUp()
{
self::$memcached->flush();
self::$memcached->quit();
self::$memcached->set('found', array('count' => 5, 'time' => strtotime('2015-01-01 00:00:00')));
self::$memcached->set('oldkey', 'old story');
$this->storage = new MemcachedStorage(self::$memcached);
}