redis 哈希(hash)函数
哈希(hash)函数
hSet 命令/方法/函数
Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned. 添加一个VALUE到HASH中。如果VALUE已经存在于HASH中,则返回FALSE。 Parameters key hashKey value Return value LONG 1 if value didn't exist and was added successfully, 0 if the value was already present and was replaced, FALSE if there was an error. Example $redis->delete('h') $redis->hSet('h', 'key1', 'hello'); /* 1, 'key1' => 'hello' in the hash at "h" */ $redis->hGet('h', 'key1'); /* returns "hello" */ $redis->hSet('h', 'key1', 'plop'); /* 0, value was replaced. */ $redis->hGet('h', 'key1'); /* returns "plop" */
hSetNx 命令/方法/函数
Adds a value to the hash stored at key only if this field isn't already in the hash. 添加一个VALUE到HASH STORE中,如果FIELD不存在。 Return value BOOL TRUE if the field was set, FALSE if it was already present. Example $redis->delete('h') $redis->hSetNx('h', 'key1', 'hello'); /* TRUE, 'key1' => 'hello' in the hash at "h" */ $redis->hSetNx('h', 'key1', 'world'); /* FALSE, 'key1' => 'hello' in the hash at "h". No change since the field wasn't replaced. */
hGet 命令/方法/函数
Gets a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. 取得HASH中的VALUE,如何HASH不存在,或者KEY不存在返回FLASE。 Parameters key hashKey Return value STRING The value, if the command executed successfully BOOL FALSE in case of failure
hLen 命令/方法/函数
Returns the length of a hash, in number of items 取得HASH表的长度。 Parameters key Return value LONG the number of items in a hash, FALSE if the key doesn't exist or isn't a hash. Example $redis->delete('h') $redis->hSet('h', 'key1', 'hello'); $redis->hSet('h', 'key2', 'plop'); $redis->hLen('h'); /* returns 2 */
hDel 命令/方法/函数
Removes a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, FALSE is returned. 删除指定的元素。 Parameters key hashKey Return value BOOL TRUE in case of success, FALSE in case of failure
hKeys 命令/方法/函数
Returns the keys in a hash, as an array of strings. 取得HASH表中的KEYS,以数组形式返回。 Parameters Key: key Return value An array of elements, the keys of the hash. This works like PHP's array_keys(). Example $redis->delete('h'); $redis->hSet('h', 'a', 'x'); $redis->hSet('h', 'b', 'y'); $redis->hSet('h', 'c', 'z'); $redis->hSet('h', 'd', 't'); var_dump($redis->hKeys('h')); Output: array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" }
hVals 命令/方法/函数
Returns the values in a hash, as an array of strings. 取得HASH表中所有的VALUE,以数组形式返回。 Parameters Key: key Return value An array of elements, the values of the hash. This works like PHP's array_values(). Example $redis->delete('h'); $redis->hSet('h', 'a', 'x'); $redis->hSet('h', 'b', 'y'); $redis->hSet('h', 'c', 'z'); $redis->hSet('h', 'd', 't'); var_dump($redis->hVals('h')); Output: array(4) { [0]=> string(1) "x" [1]=> string(1) "y" [2]=> string(1) "z" [3]=> string(1) "t" }
hGetAll 命令/方法/函数
Returns the whole hash, as an array of strings indexed by strings. 取得整个HASH表的信息,返回一个以KEY为索引VALUE为内容的数组。 Parameters Key: key Return value An array of elements, the contents of the hash. Example $redis->delete('h'); $redis->hSet('h', 'a', 'x'); $redis->hSet('h', 'b', 'y'); $redis->hSet('h', 'c', 'z'); $redis->hSet('h', 'd', 't'); var_dump($redis->hGetAll('h')); Output: array(4) { ["a"]=> string(1) "x" ["b"]=> string(1) "y" ["c"]=> string(1) "z" ["d"]=> string(1) "t" }
hExists 命令/方法/函数
Verify if the specified member exists in a key. 验证HASH表中是否存在指定的KEY-VALUE Parameters key memberKey Return value BOOL: If the member exists in the hash table, return TRUE, otherwise return FALSE. Examples $redis->hSet('h', 'a', 'x'); $redis->hExists('h', 'a'); /* TRUE */ $redis->hExists('h', 'NonExistingKey'); /* FALSE */
hIncrBy 命令/方法/函数
Increments the value of a member from a hash by a given amount. 根据HASH表的KEY,为KEY对应的VALUE自增参数VALUE。 Parameters key member value: (integer) value that will be added to the member's value Return value LONG the new value Examples $redis->delete('h'); $redis->hIncrBy('h', 'x', 2); /* returns 2: h[x] = 2 now. */ $redis->hIncrBy('h', 'x', 1); /* h[x] ← 2 + 1. Returns 3 */
hIncrByFloat 命令/方法/函数
Increments the value of a hash member by the provided float value 根据HASH表的KEY,为KEY对应的VALUE自增参数VALUE。浮点型 Parameters key member value: (float) value that will be added to the member's value Return value FLOAT the new value Examples $redis->delete('h'); $redis->hIncrByFloat('h','x', 1.5); /* returns 1.5: h[x] = 1.5 now */ $redis->hIncrByFLoat('h', 'x', 1.5); /* returns 3.0: h[x] = 3.0 now */ $redis->hIncrByFloat('h', 'x', -3.0); /* returns 0.0: h[x] = 0.0 now */
hMset 命令/方法/函数
Fills in a whole hash. Non-string values are converted to string, using the standard (string) cast. NULL values are stored as empty strings. 批量填充HASH表。不是字符串类型的VALUE,自动转换成字符串类型。使用标准的值。NULL值将被储存为一个空的字符串。 Parameters key members: key → value array Return value BOOL Examples $redis->delete('user:1'); $redis->hMset('user:1', array('name' => 'Joe', 'salary' => 2000)); $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
hMGet 命令/方法/函数
Retrieve the values associated to the specified fields in the hash. 批量取得HASH表中的VALUE。 Parameters key memberKeys Array Return value Array An array of elements, the values of the specified fields in the hash, with the hash keys as array keys. Examples $redis->delete('h'); $redis->hSet('h', 'field1', 'value1'); $redis->hSet('h', 'field2', 'value2'); $redis->hmGet('h', array('field1', 'field2')); /* returns array('field1' => 'value1', 'field2' => 'value2') */
redis 哈希(hash)函数的更多相关文章
- redis(八):Redis 哈希(Hash)
Redis 哈希(Hash) Redis hash 是一个 string 类型的 field 和 value 的映射表,hash 特别适合用于存储对象. Redis 中每个 hash 可以存储 232 ...
- Redis 哈希(Hash)
Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储对象. Redis 中每个 hash 可以存储 232 - 1 键值对(40多亿). 实例 red ...
- Redis 哈希Hash底层数据结构
1. Redis 底层数据结构 Redis数据库就像是一个哈希表,首先对key进行哈希运算得到哈希值再取模得到一个下标,每个元素是一个节点,节点之间形成链表.这感觉有点像Java中的HashMap. ...
- Redis哈希-hash
Redis的hash类型数据存储极为重要 hset K V 赋值一个hash 其中V为 (key, value) 127.0.0.1:6379> hset user id 1(integer) ...
- redis(九):Redis 哈希(Hash)(python)
# -*- coding: utf-8 -*- import redis #这个redis不能用,请根据自己的需要修改 r =redis.Redis(host="123.56.74.190& ...
- Redis中的哈希(Hash)
Redis 哈希(Hash) Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储对象. Redis 中每个 hash 可以存储 232 - 1 键值 ...
- Redis 命令,键(key),字符串(String),哈希(Hash),列表(List),集合(Set)(二)
Redis 命令 Redis 命令用于在 redis 服务上执行操作. 要在 redis 服务上执行命令需要一个 redis 客户端.Redis 客户端在我们之前下载的的 redis 的安装包中. ...
- Redis实战 - 3.Hash
hash Redis的Hash有点像一个对象(object),一个Hash里面可以存多个Key-Value对作为它的field,所以它通常可以用来表示对象. Hash里面能存放的值也能作为String ...
- redist命令操作(二)--哈希Hash,列表List
1.Redis 哈希(Hash) 参考菜鸟教程:http://www.runoob.com/redis/redis-hashes.html Redis hash 是一个string类型的field和v ...
随机推荐
- django-request对象
HTTP 应用的信息是通过 请求报文 和 响应报文 传递的,关于更多的相关知识,可以阅读<HTTP权威指南>获得. 其中 请求报文 由客户端发送,其中包含和许多的信息,而 django 将 ...
- 机器学习方法、距离度量、K_Means
特征向量 1.特征向量:以人为例,每个元素可能就对应这人的某些方面,这就是特征,例如:身高.年龄.性别.国际....2.特征工程:目的就是将现有数据中可作为信号的特征与那些仅是噪声的特征区分开来:当数 ...
- poj2976 Dropping tests(01分数规划 好题)
https://vjudge.net/problem/POJ-2976 又是一波c++AC,g++WA的题.. 先推导公式:由题意得 Σa[i]/Σb[i]<=x,二分求最大x.化简为Σ(a[i ...
- __x__(29)0908第五天__高度塌陷 问题
高度塌陷 在文档流中,父元素的高度默认是被子元素撑开的. 但是当为 子元素 设置 float 时,子元素会完全脱离文档流,无法再撑开父元素,导致父元素高度塌陷...以致于布局混乱 变成 BFC块级格式 ...
- Windows系统IntelliJ IDEA安装配置
IntelliJ IDEA安装 IntelliJ IDEA,是java编程语言开发的集成环境,业界公认的最好的Java开发IDE之一.打开IDEA官方网站https://www.jetbrains.c ...
- Lecture4_1&4_2.多维随机变量及其概率分布
1.二维随机变量(X,Y)的联合分布函数: F(x,y)=P(X≤x,Y≤y) 2.二维随机变量(X,Y)关于X的边缘分布函数: FX(x)=P(X≤x) =P(X≤x,Y<+∞) =F(x,+ ...
- Viterbi algorithm
HMM(隐马尔可夫模型)是用来描述隐含未知参数的统计模型,是一个关于时序的概率模型,它描述了一个由隐藏的马尔可夫链生成状态序列,再由状态序列生成观测序列的过程.其中,状态之间的转换以及观测序列和状态序 ...
- Python 模块定义、导入、优化详解
一.定义 模块:用来从逻辑上组织 python 代码(变量,函数,类, 逻辑:实现一个功能),本质就是 .py 结尾的 python文件(例如:test.py文件,对应的模块名:test) 包:用来从 ...
- awk 复习
awk 的再次学习!!!! awk 的一般模式 awk '{parttern + action }' {filename} , 提取/etc/passwd 的用户 awk -F ":&quo ...
- Spring Security Session并发控制原理解析
当使用spring security 的标签,如下,其中<sec:session-management>对应的SessionManagementFilter.从名字可以看出,这是一个管理S ...