首页 > php教程 > php手册 > 正文

php-redis中文参考手册_Ping_echo_set_get_setex_psetex_...

php中文网
发布: 2016-06-13 10:50:50
原创
1833人浏览过

ping
Description
Check the current connection status

检查当前连接实例的状态

Parameters
(none)

Return Value
STRING: +PONG on success. Throws a RedisException object on connectivity error, as described above.

如果失败,Throws一个RedisException对象报出连接错误。

echo
Description
Sends a string to Redis, which replies with the same string

发送一个字符串到Redis,返回一个相同的字符串

Parameters
STRING: The message to send.

Return Value
STRING: the same message.

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和值返回值。

立即学习PHP免费学习笔记(深入)”;

Examples
$redis->get('key');
set
Description
Set the string value in argument as value of the key.

设置值到KEY

HTML5+CSS3中文参考手册(3手册)
HTML5+CSS3中文参考手册(3手册)

HTML5+CSS3中文参考手册(3手册)

HTML5+CSS3中文参考手册(3手册) 1087
查看详情 HTML5+CSS3中文参考手册(3手册)

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, psetex
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.
$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 */
del, delete
Description
Remove specified keys.

移除已经存在KEYS   www.2cto.com

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 */


作者:四云麒麟
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号