字符串(string)函数

get 命令/方法/函数
Description Get the value related to the specified key 取得与指定的键值相关联的值 Parameters key Return Value String or Bool: If key didn't exist, FALSE is returned. Otherwise, the value related to this key is returned. 返回相关值或者BOOL值,如果KEY不存在,返回FALSE。如果有相关的KEY和值返回值。 Examples $redis->get('key');
set 命令/方法/函数
Description Set the string value in argument as value of the key. 设置值到KEY Parameters Key Value Timeout (optional). Calling SETEX is preferred if you want a timeout. Return value Bool TRUE if the command is successful. Examples $redis->set('key', 'value');
setex 命令/方法/函数
Description Set the string value in argument as value of the key, with a time to live. PSETEX uses a TTL in milliseconds. 设置一个有生命周期的KEY-VALUE,psetex()使用的周期单位为毫秒。 Parameters Key TTL Value Return value Bool TRUE if the command is successful. Examples $redis->setex('key', 3600, 'value'); // sets key → value, with 1h TTL.
psetex 命令/方法/函数
Description Set the string value in argument as value of the key, with a time to live(milliseconds). 设置一个有生命周期的KEY-VALUE,psetex()使用的周期单位为毫秒。 Return value Bool TRUE if the command is successful. Examples $redis->psetex('key', 100, 'value'); // sets key → value, with 0.1 sec TTL.
setnx 命令/方法/函数
Description Set the string value in argument as value of the key if the key doesn't already exist in the database. setnx用于设置一个KEY-VALUE,这个函数会先判断Redis中是否有这个KEY,如果没有就SET,有就返回False。 Parameters key value Return value Bool TRUE in case of success, FALSE in case of failure. Examples $redis->setnx('key', 'value'); /* return TRUE */ $redis->setnx('key', 'value'); /* return FALSE */
delete 命令/方法/函数
Description Remove specified keys. 移除已经存在KEYS Parameters An array of keys, or an undefined number of parameters, each a key: key1 key2 key3 ... keyN 可以是一个KEYS的数组,或者一个未定义的数字参数,或者一个一个的写KEY Return value Long Number of keys deleted. 返回删除KEY-VALUE的数量 Examples $redis->set('key1', 'val1'); $redis->set('key2', 'val2'); $redis->set('key3', 'val3'); $redis->set('key4', 'val4'); $redis->delete('key1', 'key2'); /* return 2 */ $redis->delete(array('key3', 'key4')); /* return 2 */
getSet 命令/方法/函数
Description Sets a value and returns the previous entry at that key. 设置一个VALUE 并且返回该KEY当前的VALUE。 Parameters Key: key STRING: value Return value A string, the previous value located at this key. Example $redis->set('x', '42'); $exValue = $redis->getSet('x', 'lol'); // return '42', replaces x by 'lol' $newValue = $redis->get('x')' // return 'lol'
multi, exec, discard 命令/方法/函数
Description Enter and exit transactional mode. 进入、退出事务处理模式。 Parameters (optional) Redis::MULTI or Redis::PIPELINE. Defaults to Redis::MULTI. A Redis::MULTI block of commands runs as a single transaction; a Redis::PIPELINE block is simply transmitted faster to the server, but without any guarantee of atomicity. discardcancels a transaction. multi函数的参数选项为Redis::MULTI或者是Redis::PIPELINE.默认的是参数是Redis::MULTI。 Redis::MULTI将多个操作当做一个事务来处理。Redis::PIPELINE将作为一个简单快速的处理通道给服务器进行处理,但是不保证处理数据的原子性。 discard()函数取消一个事物处理模式。 Return value multi() returns the Redis instance and enters multi-mode. Once in multi-mode, all subsequent method calls return the same object until exec() is called. multi()返回一个Redis实例,并且这个实例进入到了事务处理模式(批量处理)。当进入到事务处理模式,所有的方法调用都将返回相同的Redis实例,一直到exec()被调用执行事务处理。 Example $ret = $redis->multi() ->set('key1', 'val1') ->get('key1') ->set('key2', 'val2') ->get('key2') ->exec(); /* $ret == array( 0 => TRUE, 1 => 'val1', 2 => TRUE, 3 => 'val2'); */
watch 命令/方法/函数
Description Watches a key for modifications by another client. If the key is modified between WATCH and EXEC, the MULTI/EXEC transaction will fail (return FALSE). 监控一个KEY是否被其他的客户端修改。如果KEY在调用watch()和exec()之间被修改,那么批量处理最终的exec()执行将失败。通过一些实验,这个函数的效果其实并没有那么好,或者说不能够准确的去监控。 Parameters keys: a list of keys Example $redis->watch('x'); /* long code here during the execution of which other clients could well modify `x` */ $ret = $redis->multi() ->incr('x') ->exec(); /* $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC. */
unwatch 命令/方法/函数
Description unwatch cancels all the watching of all keys by this client. unwatch()取消对于所有KEY值的监控操作针对于这个Redis实例。通过一些实验,这个函数的效果其实并没有那么好,或者说不能够准确的去监控。
subscribe 命令/方法/函数
Description Subscribe to channels. Warning: this function will probably change in the future. 方法回调函数,注意:该方法在将来有可能被修改。 Parameters channels: an array of channels to subscribe to callback: either a string or an array($instance, 'method_name'). The callback function receives 3 parameters: the redis instance, the channel name, and the message. Example function f($redis, $chan, $msg) { switch($chan) { case 'chan-1': ... break; case 'chan-2': ... break; case 'chan-2': ... break; } } $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
publish 命令/方法/函数
Description Publish messages to channels. Warning: this function will probably change in the future. 将消息发布到信道。警告:这个功能可能会在未来发生变化。 Parameters channel: a channel to publish to messsage: string Example $redis->publish('chan-1', 'hello, world!'); // send message.
exists 命令/方法/函数
Description Verify if the specified key exists. 验证一个指定的KEY是否存在。 Parameters key Return value BOOL: If the key exists, return TRUE, otherwise return FALSE. BOOL:如果key存在,返回true,否则返回false。 Examples $redis->set('key', 'value'); $redis->exists('key'); /* TRUE */ $redis->exists('NonExistingKey'); /* FALSE */
incr 命令/方法/函数
Description Increment the number stored at key by one. If the second argument is filled, it will be used as the integer value of the increment. 对指定的KEY的值自增1。如何填写了第二个参数,将把第二个参数自增给KEY的值。 Parameters key value: value that will be added to key (only for incrBy) Return value INT the new value 返回新的INT数值 Examples $redis->incr('key1'); /* key1 didn't exists, set to 0 before the increment 如果key1不存在,在自增之前的默认值为0 */ /* and now has the value 1 执行incr后,现在为1 */ $redis->incr('key1'); /* 2 */ $redis->incr('key1'); /* 3 */
incrBy 命令/方法/函数
Description 对key的值加num,比如 incrby("ab", 10),相当于:ab+10 Return value INT the new value 返回新的INT数值 Examples $redis->incrBy('key1', 10); /* 如果key1的值为8,那么结果为:18 */
incrByFloat 命令/方法/函数
Increment the key with floating point precision. 自增一个浮点型的数值。 Parameters key value: (float) value that will be added to the key Return value FLOAT the new value Examples $redis->incrByFloat('key1', 1.5); /* key1 didn't exist, so it will now be 1.5 */ $redis->incrByFloat('key1', 1.5); /* 3 */ $redis->incrByFloat('key1', -1.5); /* 1.5 */ $redis->incrByFloat('key1', 2.5); /* 3.5 */
decr 命令/方法/函数
对指定的KEY的值自减1(如果要自减指定的值,可以使用decrBy) Parameters key value: value that will be substracted to key (only for decrBy) Return value INT the new value Examples $redis->decr('key1'); /* key1 didn't exists, set to 0 before the increment */ /* and now has the value -1 */ $redis->decr('key1'); /* -2 */ $redis->decr('key1'); /* -3 */
decrBy 命令/方法/函数
减去指定的值。 Return value INT the new value Examples $redis->set('key1', 50); $redis->decrBy('key1', 10); /* result:40 */
mGet 命令/方法/函数
Description Get the values of all the specified keys. If one or more keys dont exist, the array will contain FALSE at the position of the key. 取得所有指定KEYS的值,如果一个或者更多的KEYS不存在,那么返回的ARRAY中将在相应的KEYS的位置填充FALSE。 Parameters Array: Array containing the list of the keys 数组:一个KEYS的数组 Return value Array: Array containing the values related to keys in argument 数组:返回相应的KEYS的值 Examples $redis->set('key1', 'value1'); $redis->set('key2', 'value2'); $redis->set('key3', 'value3'); $redis->mGet(array('key1', 'key2', 'key3')); /* array('value1', 'value2', 'value3'); $redis->mGet(array('key0', 'key1', 'key5')); /* array(`FALSE`, 'value2', `FALSE`);
append 命令/方法/函数
Description Append specified string to the string stored in specified key. 添加指定的字符串到指定的字符串KEY。 Parameters Key Value Return value INTEGER: Size of the value after the append 返回添加后KEY的SIZE Example $redis->set('key', 'value1'); $redis->append('key', 'value2'); /* 12 */ $redis->get('key'); /* 'value1value2' */
getRange 命令/方法/函数
getRange(substr also supported but deprecated in redis) Description Return a substring of a larger string 返回字符串的一部分 Parameters key start end Return value STRING: the substring Example $redis->set('key', 'string value'); $redis->getRange('key', 0, 5); /* 'string' */ $redis->getRange('key', -5, -1); /* 'value' */
setRange 命令/方法/函数
Description Changes a substring of a larger string. 修改字符串的一部分。 Parameters key offset value Return value STRING: the length of the string after it was modified. Example $redis->set('key', 'Hello world'); $redis->setRange('key', 6, "redis"); /* returns 11 */ $redis->get('key'); /* "Hello redis" */
strlen 命令/方法/函数
Description Get the length of a string value. 返回字符串的长度。 Parameters key Return value INTEGER Example $redis->set('key', 'value'); $redis->strlen('key'); /* 5 */
getBit 命令/方法/函数
Description Return a single bit out of a larger string 将一个位返回一个较大的字符串 Parameters key offset Return value LONG: the bit value (0 or 1) Example $redis->set('key', "\x7f"); // this is 0111 1111 $redis->getBit('key', 0); /* 0 */ $redis->getBit('key', 1); /* 1 */
setBit 命令/方法/函数
Description Changes a single bit of a string. Parameters key offset value: bool or int (1 or 0) Return value LONG: 0 or 1, the value of the bit before it was set. Example $redis->set('key', "*"); // ord("*") = 42 = 0x2f = "0010 1010" $redis->setBit('key', 5, 1); /* returns 0 */ $redis->setBit('key', 7, 1); /* returns 0 */ $redis->get('key'); /* chr(0x2f) = "/" = b("0010 1111") */
bitop 命令/方法/函数
Description Bitwise operation on multiple keys.
对一个或多个保存二进制位的字符串 key 进行位元操作,并将结果保存到 destkey 上。 Parameters operation: either "AND", "OR", "NOT", "XOR" ret_key: return key key1 key2... Return value LONG: The size of the string stored in the destination key.
bitcount 命令/方法/函数
Description Count bits in a string. Parameters key Return value LONG: The number of bits set to 1 in the value behind the input key. example
https://blog.csdn.net/ma_jiang/article/details/61421888
mset 命令/方法/函数
Description Sets multiple key-value pairs in one atomic command. MSETNX only returns TRUE if all the keys were set (see SETNX). 批量设置多个KEY-VALUE。如果所有的KEYS都被设置成功,如果这些KEY-VALUE都SET成功,使用msetnx将仅仅返回一个TURE,而如果有一个是已经存在的KEY,则所有的操作都不被执行。 Parameters Pairs: array(key => value, ...) Return value Bool TRUE in case of success, FALSE in case of failure. Example $redis->mset(array('key0' => 'value0', 'key1' => 'value1')); var_dump($redis->get('key0')); var_dump($redis->get('key1')); Output: string(6) "value0" string(6) "value1"

redis 字符串(string)函数的更多相关文章

  1. Python操作redis字符串(String)详解 (三)

    # -*- coding: utf-8 -*- import redis #这个redis不能用,请根据自己的需要修改 r =redis.Redis(host=") 1.SET 命令用于设置 ...

  2. Redis字符串(STRING)中BIT相关命令

    上篇文章我们对STRING数据类型中一些基本的命令进行了介绍,但是没有涉及到BIT相关的命令,本文我们就来看看几个和BIT相关的命令. 本文是Redis系列的第四篇文章,了解前面的文章有助于更好的理解 ...

  3. Redis 字符串(String)

      Redis 字符串数据类型的相关命令用于管理 redis 字符串值,基本语法如下: 语法 redis 127.0.0.1:6379> COMMAND KEY_NAME 实例 redis 12 ...

  4. redis(六):Redis 字符串(String)

    Redis 字符串数据类型的相关命令用于管理 redis 字符串值,基本语法如下: 语法 redis 127.0.0.1:6379> COMMAND KEY_NAME 实例 redis 127. ...

  5. redis -字符串string

    字符串类型是Redis 中最为基础的数据存储类型,它在Redis 中是二进制安全的,该类型可以接收任何格式的数据,  字符串 Value 最多可以容纳的数据长度是521M. 保存: 设置键值. set ...

  6. (二)Redis字符串String操作

    String全部命令如下: set key value # 设置一个key的value值 get key # 获取key的value值 mset key1 value1 key2 value2 ... ...

  7. redis(七):Redis 字符串(String)(python)

    # -*- coding: utf-8 -*- import redis #这个redis不能用,请根据自己的需要修改 r =redis.Redis(host="123.516.74.190 ...

  8. C#字符串string以及相关内置函数

    C#字符串string函数 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享. ...

  9. Redis 命令,键(key),字符串(String),哈希(Hash),列表(List),集合(Set)(二)

      Redis 命令 Redis 命令用于在 redis 服务上执行操作. 要在 redis 服务上执行命令需要一个 redis 客户端.Redis 客户端在我们之前下载的的 redis 的安装包中. ...

随机推荐

  1. Redis新接触

    一.redis简介 redis即Remote Dictionary Server,是一个key—value存储系统. 二.优点 1.redis支持的存储类型较多,如String.List.Hash.s ...

  2. Educational Codeforces Round 7

    622A - Infinite Sequence    20171123 暴力枚举\(n\)在哪个区间即可,时间复杂度为\(O(\sqrt{n})\) #include<stdlib.h> ...

  3. static和extern的用法小结

    以前写程序是,基本不管static和extern,一个工程文件也只有一个c文件.今天尝试用多个文件来写,自然就涉及到这两个关键词的使用,自己查了些资料,并且做了些实验,总结如下. extern的用法 ...

  4. OO第四次博客作业

    测试与正确性论证的效果差异及其优缺点 测试是利用测试代码,通过编写测试用例来验证代码是否能正常完成所要求的功能,自动测试相较于正确性论证来说更加的直观,直接测试代码的功能,而正确性论证是在JSF的基础 ...

  5. 常用的当前时间(返回String类型)

    public class TimeUtil { /** * 创建人:zhiyuan * 创建时间:2018年6月9日上午11:31:02 * 方法描述:以yyyy-MM-dd查询当前时间 */ pub ...

  6. 工具包分享-常用工具。by-某某

    下载地址: 链接:http://pan.baidu.com/s/1hsseqm4 密码:a6rc 里面的工具全部来自互联网,本人不是工具的生产者,只是它的收集工. 都是一些很常用,顺手的工具,仅用于技 ...

  7. 如何将两个PDF文件合并到一个页面中

    在目前职场办公中,很多使用的文件格式是PDF文件格式,由于工作的需要,经常需要将PDF文件合并在一起,但由于PDF文件不能直接编辑修改,不能OFFICE,WPS那样,通过复制粘贴将两者合并,那如何解决 ...

  8. Python全栈-magedu-2018-笔记8

    第四章 - IPython 使用 帮助 ? Ipython的概述和简介 help(name) 查询指定名称的帮助,是python帮助 obj? 列出obj对象的详细信息 obj?? 列出更加详细的信息 ...

  9. TPS6116x 1-wire总线的分析与驱动实现

    1-wire总线的特点 1-wire协议是用一条数据线作为总线进行数据通信的协议. 1-wire总线有以下特点: 1. 可以组建网络,个数没有限制. 2. 使用GPIO的特性就可以,不需要专门的控制器 ...

  10. SNMP 优秀帖子

    -- 比较系统的描述http://blog.sina.com.cn/s/blog_54837cf301011607.html 几个SNMP官方网站(搜索关键字:snmplibrary C#):http ...