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


PHP Client::hmset方法代码示例

本文整理汇总了PHP中Predis\Client::hmset方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::hmset方法的具体用法?PHP Client::hmset怎么用?PHP Client::hmset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Predis\Client的用法示例。


在下文中一共展示了Client::hmset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAllIndexed

 /**
  * @inheritDoc
  */
 public function getAllIndexed() : array
 {
     if (!$this->client->exists($this->key)) {
         $data = $this->repository->getAllIndexed();
         if ($data) {
             $this->client->hmset($this->key, $data);
         }
     } else {
         $data = $this->client->hgetall($this->key);
     }
     return $data;
 }
开发者ID:igaponov,项目名称:shop,代码行数:15,代码来源:DirectoryViewRepository.php

示例2: haveInRedis

 /**
  * Creates or modifies keys
  *
  * If $key already exists:
  *
  * - Strings: its value will be overwritten with $value
  * - Other types: $value items will be appended to its value
  *
  * Examples:
  *
  * ``` php
  * <?php
  * // Strings: $value must be a scalar
  * $I->haveInRedis('string', 'Obladi Oblada');
  *
  * // Lists: $value can be a scalar or an array
  * $I->haveInRedis('list', ['riri', 'fifi', 'loulou']);
  *
  * // Sets: $value can be a scalar or an array
  * $I->haveInRedis('set', ['riri', 'fifi', 'loulou']);
  *
  * // ZSets: $value must be an associative array with scores
  * $I->haveInRedis('set', ['riri' => 1, 'fifi' => 2, 'loulou' => 3]);
  *
  * // Hashes: $value must be an associative array
  * $I->haveInRedis('hash', ['obladi' => 'oblada']);
  * ```
  *
  * @param string $type  The type of the key
  * @param string $key   The key name
  * @param mixed  $value The value
  *
  * @throws ModuleException
  */
 public function haveInRedis($type, $key, $value)
 {
     switch (strtolower($type)) {
         case 'string':
             if (!is_scalar($value)) {
                 throw new ModuleException($this, 'If second argument of haveInRedis() method is "string", ' . 'third argument must be a scalar');
             }
             $this->driver->set($key, $value);
             break;
         case 'list':
             $this->driver->rpush($key, $value);
             break;
         case 'set':
             $this->driver->sadd($key, $value);
             break;
         case 'zset':
             if (!is_array($value)) {
                 throw new ModuleException($this, 'If second argument of haveInRedis() method is "zset", ' . 'third argument must be an (associative) array');
             }
             $this->driver->zadd($key, $value);
             break;
         case 'hash':
             if (!is_array($value)) {
                 throw new ModuleException($this, 'If second argument of haveInRedis() method is "hash", ' . 'third argument must be an array');
             }
             $this->driver->hmset($key, $value);
             break;
         default:
             throw new ModuleException($this, "Unknown type \"{$type}\" for key \"{$key}\". Allowed types are " . '"string", "list", "set", "zset", "hash"');
     }
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:65,代码来源:Redis.php

示例3: recoverByRemoteAddress

 /**
  * @param string $remoteAddress
  *
  * @return Session|null
  */
 public function recoverByRemoteAddress($remoteAddress)
 {
     $session = null;
     $oracleData = $this->findSessionInOracleByRemoteAddress($remoteAddress);
     if (count($oracleData) === 1) {
         $sid = $oracleData[0]['sid'];
         $redisKey = $this->buildKey($sid);
         $data = $this->redis->hgetall($redisKey);
         if (!$data) {
             $data['userId'] = (int) $oracleData[0]['userId'];
             $data['userScreenname'] = $oracleData[0]['userScreenname'];
         }
         $this->redis->hmset($redisKey, $data);
         $this->redis->expire($redisKey, $this->getExpires());
         $session = new Session($sid, $this->getRealm(), $data);
     }
     return $session;
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:23,代码来源:OracleHookedRedisSessionProvider.php

示例4: createSession

 /**
  * @param array $userInfo
  */
 public function createSession($sessionId, $userInfo)
 {
     $this->redis->hmset('session_' . $sessionId, $userInfo);
 }
开发者ID:squarer,项目名称:symfony3-demo,代码行数:7,代码来源:AppExtension.php

示例5: save

 /**
  * @inheritDoc
  */
 public function save(CustomerView $view)
 {
     $this->client->hmset(self::KEY . ':' . $view->getId(), ['id' => $view->getId(), 'email' => $view->getEmail(), 'country' => $view->getCountry(), 'city' => $view->getCity(), 'street' => $view->getStreet(), 'zipCode' => $view->getZipCode()]);
 }
开发者ID:igaponov,项目名称:shop,代码行数:7,代码来源:CustomerViewRepository.php

示例6: htInitByDefault

 /**
  * 通过默认值来初始化一个 hash table
  * @param $key
  * @param array $fields
  * @param int $default
  * @return mixed
  */
 public function htInitByDefault($key, array $fields, $default = 0)
 {
     $data = array_fill_keys($fields, $default);
     return $this->redis->hmset($key, $data);
 }
开发者ID:inhere,项目名称:php-librarys,代码行数:12,代码来源:Redis.php

示例7: serialize

 *
 * Created by PhpStorm.
 * User: shruti
 * Date: 8/7/15
 * Time: 12:32 PM
 */
include "Utils.php";
//Class for Data cleaning
require_once 'vendor/autoload.php';
use Predis;
Predis\Autoloader::register();
$client = new Predis\Client(["hosts" => "localhost", "port" => "6379"]);
//store file contents in data variable
$json_data = file_get_contents('./Crawled-data.json');
//decode the json data into array variable
$json_array = json_decode($json_data, true);
//Clean entire file data
for ($i = 0; $i < count($json_array); $i++) {
    $json_array[$i] = Utils::cleanData($json_array[$i]);
}
//Creating Hashmap in redis
foreach ($json_array as $element) {
    //serialize each element before storing as redis accept string
    $serial_data = serialize($element);
    //store partnumber in key var
    $key = $element['ModelId'];
    //replace spaces in partnumber field
    $key = str_replace(" ", "", $key);
    //create hashmap using partnumber as key
    $client->hmset('Laptop_Specification', $key, $serial_data);
}
开发者ID:shrutijain27,项目名称:Crawler,代码行数:31,代码来源:LoadData_to_Redis.php


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