當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。