本文整理汇总了PHP中Predis\Client::hset方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::hset方法的具体用法?PHP Client::hset怎么用?PHP Client::hset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::hset方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* {@inheritDoc}
*/
public function add($source, $type, $unique, array $data, \DateTime $timestamp = null)
{
$identifier = base64_encode(implode(':', [$source, $type, $unique]));
$timestamp = $timestamp ?: new \DateTime();
$this->redis->hset('aggregator:objects', $identifier, json_encode(['source' => $source, 'type' => $type, 'unique' => $unique, 'data' => $data, 'timestamp' => $timestamp->format('U')]));
$this->redis->zadd("aggregator:sources:{$source}", $timestamp->format('U'), $identifier);
}
示例2: persist
/**
* @param Extension $extension
* @param User $extension
*/
public function persist(Extension $extension, User $user)
{
$this->redisClient->hset(self::EXTENSION_HASH_STORE, $extension->getName(), $extension->serialize());
$this->redisClient->hset(self::EXTENSION2USER_HASH_STORE, $extension->getName(), $user->getName());
$meta = ['watchers' => $extension->getStars(), 'stars' => $extension->getWatchers()];
$this->redisClient->hset(self::EXTENSIONMETA_HASH_STORE, $extension->getName(), json_encode($meta));
}
示例3: createRate
public function createRate($key, $limit, $period)
{
$this->client->hset($key, 'limit', $limit);
$this->client->hset($key, 'calls', 1);
$this->client->hset($key, 'reset', time() + $period);
$this->client->expire($key, $period);
return $this->getRateInfo($key);
}
示例4: write
/**
* Writes session data.
*
* @param string $id A session ID
* @param string $data A serialized chunk of session data
*
* @return bool true, if the session was written, otherwise an exception is thrown
*
* @throws \RuntimeException If the session data cannot be written
*/
public function write($key, $data)
{
$result = $this->db->hset($this->getHashKey(), $key, serialize($data));
$expires = (int) $this->options['lifetime'];
if ($expires > 0) {
$this->db->expire($this->getHashKey(), $expires);
}
return $result;
}
示例5: getById
/**
* @param $id
* @return DirectoryView
*/
public function getById($id) : DirectoryView
{
if (!($name = $this->client->hget($this->key, $id))) {
$model = $this->repository->getById($id);
$this->client->hset($this->key, $model->getId(), $model->getName());
return $model;
}
/** @var DirectoryView $viewClass */
$viewClass = $this->viewClass;
return $viewClass::create($id, $name);
}
示例6: add
/**
* @param array $payload
*
* @return int
*
* @throws \InvalidArgumentException
*/
public function add(array $payload)
{
if (!isset($payload['fireTime'])) {
throw new \InvalidArgumentException('payload should has key: fireTime, and >0');
}
$fireTime = $payload['fireTime'];
$key = $this->makeKey($fireTime);
$value = json_encode($payload);
$field = md5($value);
$ret = $this->client->hset($key, $field, $value);
// var_dump(__METHOD__ . ": key[$key] field[$field] value[$value] hset return " . var_export($ret, true));
return $ret;
}
示例7: dumpConfig
/**
* Dump config array to redis.
*
* @param array $conf
* @return $this
*/
public function dumpConfig($conf = null)
{
if (is_null($conf)) {
$conf = $this->conf;
}
if (is_array($conf) && $this->redis) {
foreach ($conf as $k => $value) {
$this->redis->hset($this->key, $k, serialize($value));
}
}
return $this;
}
示例8: setRoutingDestination
/**
* @param string $destination
* @param string $commandName
* @param string $routingKey
*/
public function setRoutingDestination($destination, $commandName, $routingKey)
{
$this->client->hset(self::COMMAND_ROUTING_KEY, $this->hashCommandRouting($commandName, $routingKey), $destination);
}
示例9: Report
public function Report()
{
$json = json_encode(array("worker_id" => $this->worker_id, "worker_hash" => $this->worker_hash, "worker_version" => $this->worker_version, "time_limit" => $this->time_limit, "end_time" => $this->end_time, "last_word" => $this->last_word, "last_def" => $this->last_def, "status" => $this->status));
$this->redis->hset('worker.status', $this->worker_id, $json);
}
示例10: doLog
/**
* @inheritdoc
*/
protected function doLog($ident, $originalId, array $context)
{
$this->predis->hset($ident, $originalId, json_encode($context));
}
示例11: add
/**
* {@inheritdoc}
*/
public function add(string $alias, FeatureInterface $feature) : StorageInterface
{
$this->redis->hset($this->prefix, $alias, $this->feature($feature));
return $this;
}
示例12: log
/**
* @inheritdoc
*/
public function log($id, $originalId, array $context)
{
$this->predis->hset($id, $originalId, json_encode($context));
}
示例13: Logger
// create a log channel
$log = new Logger('serverlog');
$log->pushHandler(new StreamHandler(dirname(__DIR__) . '/' . $config['client']['log_file']));
//get params
if (!$_REQUEST['sender'] || !$_REQUEST['receiver'] || !$_REQUEST['text']) {
$log->error('Invalid request');
header("HTTP/1.1 420 OK");
die("ERR 110");
}
$client = new PredisClient($config['redis_conn_url']);
$bulkNum = (int) $client->get(BULK_COUNTER);
$bulkNum++;
$client->set(BULK_COUNTER, $bulkNum);
$message = json_encode($_REQUEST);
//store message
$client->hset(BULK_HASH, $bulkNum, $message);
$client->publish('bulkmocksend', $message);
$client->quit();
$messageId = BulkUtils::guid();
$smsParts = BulkUtils::getNumberOfSMSsegments($_REQUEST['text']);
ob_start();
//close http conn. and flush
header("HTTP/1.1 202 OK");
echo "OK {$messageId} {$smsParts}";
$log->info("Valid request and replied: OK {$messageId} {$smsParts}");
header('Connection: close');
header('Content-Length: ' . ob_get_length());
ob_end_flush();
ob_flush();
flush();
//proceed with dlr
示例14: remCache
/**
* Store a value serialized into the cache.
* @param string $id
* @param string $method
* @param array $args
* @param mixed $value
*/
private static function remCache(Key $key, $args, $value)
{
self::$_redis->hset($key, 'args', serialize($args));
self::$_redis->hset($key, 'val', serialize($value));
self::remAddIndex($key);
}