ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
// 普通 set/get 操作 ~~~ $redis->set('test:str1', 'predis'); $ret = $redis->get('test:str1'); echo $ret; ~~~ // setnx 只有在 key 不存在时设置 key 的值 ~~~ $redis->setnx('test:str3', 'str3-v'); $ret = $redis->get('test:str3'); echo $ret; ~~~ // incrby/incr/decrby/decr 对值的递增和递减 ~~~ $redis->set('test:str2', 1); $redis->incr('test:str2'); $redis->incrby('test:str2', 4); echo $redis->decr('test:str2'); echo $redis->decrby('test:str2', 2); echo $redis->get('test:str2'); ~~~