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


PHP Client::hset方法代码示例

本文整理汇总了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);
 }
开发者ID:nonconforme,项目名称:aggregator,代码行数:10,代码来源:RedisAggregator.php

示例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));
 }
开发者ID:Doanlmit,项目名称:pickleweb,代码行数:11,代码来源:ExtensionRepository.php

示例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);
 }
开发者ID:Privax,项目名称:RateLimitBundle,代码行数:8,代码来源:Redis.php

示例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;
 }
开发者ID:realestateconz,项目名称:SncRedisBundle,代码行数:19,代码来源:RedisSessionStorage.php

示例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);
 }
开发者ID:igaponov,项目名称:shop,代码行数:15,代码来源:DirectoryViewRepository.php

示例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;
 }
开发者ID:jiangyu7408,项目名称:notification,代码行数:20,代码来源:RedisStorage.php

示例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;
 }
开发者ID:wwtg99,项目名称:config,代码行数:18,代码来源:RedisSource.php

示例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);
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:9,代码来源:RedisTemplate.php

示例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);
 }
开发者ID:Grosloup,项目名称:PHP-Workers-Tutorial,代码行数:5,代码来源:worker.php

示例10: doLog

 /**
  * @inheritdoc
  */
 protected function doLog($ident, $originalId, array $context)
 {
     $this->predis->hset($ident, $originalId, json_encode($context));
 }
开发者ID:treehouselabs,项目名称:io-bundle,代码行数:7,代码来源:PredisItemLogger.php

示例11: add

 /**
  * {@inheritdoc}
  */
 public function add(string $alias, FeatureInterface $feature) : StorageInterface
 {
     $this->redis->hset($this->prefix, $alias, $this->feature($feature));
     return $this;
 }
开发者ID:jadb,项目名称:feature_toggle,代码行数:8,代码来源:RedisStorage.php

示例12: log

 /**
  * @inheritdoc
  */
 public function log($id, $originalId, array $context)
 {
     $this->predis->hset($id, $originalId, json_encode($context));
 }
开发者ID:mvanduijker,项目名称:FMIoBundle,代码行数:7,代码来源:PredisItemLogger.php

示例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
开发者ID:rukavina,项目名称:sms-bulk-mock,代码行数:31,代码来源:bulk-server.php

示例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);
 }
开发者ID:chriskite,项目名称:rem,代码行数:13,代码来源:Rem.php


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