安装php的redis扩展(/usr/local/servers/php73/bin/php --ini 可以查看php.ini所在的位置)

	tar -zxvf redis-5.1.1.tgz
	cd redis-5.1.1
	mv redis-5.1.1 /usr/local/servers/redis-php-5.1.1
	cd redis-php-5.1.1/
	
	/usr/local/servers/php73/bin/phpize	
	如果报错:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
	yum install autoconf
		
	/usr/local/servers/php73/bin/phpize	
	./configure --with-php-config=/usr/local/servers/php73/bin/php-config
	make
	echo $?
	make install
	
	//重新编译exif, 
	cd /usr/local/servers/php-7.3.7/ext/exif
	/usr/local/servers/php73/bin/phpize	
	./configure --with-php-config=/usr/local/servers/php73/bin/php-config
	make && make install
	vi /usr/local/servers/php73/etc/php.ini ;extension=exif.so 冒号去掉 

redis安装用docker方式 :http://www.diyyq.com/kaifahuanjing/5.html

/usr/local/servers/redis_server57/bin/redis-cli -h 127.0.0.1 -p 6379 -a my123456
keys *   //取出所有key
keys my*  //模糊匹配
hmget member:account:78:data:1 expire_time access_token //获取哈希的值
hgetAll member:account:78:data:1						//获取哈希所有值
smembers clear:all:member:account:member_id				//获取集合
select 1  	//切换db1
flushdb 		//删除当前数据库中的所有Key
flushall 		//删除所有数据库中的key
del 			//php-redis 5 版本弃用了delete()方式删除

$redis->lrem($redisPrefix.":id", $key, 0);	//删除列表id-列表中的数据(可以删除队列)	
$redis->del($redisPrefix.":data:".$key);	//删除哈希中的数据,//php-redis 5 版本弃用了delete()方式删除
$redis->decr($redisPrefix.':key');			//incr 还是得从1开始	
$redis->srem('clear:all:member:account:member_id',$memberId);//删除集合下的管理员id-可以删除集合	
$redis->setex('wll',60,1);//设置redis: (key,X秒后超时,value) 
$redis->expire('order:notify:count:'.$orderId,$expireTime);//设置有效时间: key , X秒后超时 		

redis中incr、incrby、decr、decrby属于string数据结构,它们是原子性递增或递减操作。
	说明:https://www.cnblogs.com/sealedbook/p/6194047.html
 incr递增1并返回递增后的结果;
	decr递减1并返回递减后的结果;
		
 incrby根据指定值做递增或递减操作并返回递增或递减后的结果(incrby递增或递减取决于传入值的正负); 
 decrby根据指定值做递增或递减操作并返回递增或递减后的结果(decrby递增或递减取决于传入值的正负);

HyperLogLog(不精确的去重计数方案)-用来做在线人数,挺不错的 说明:https://www.cnblogs.com/HKUI/p/10520628.html

	127.0.0.1:6379> get lan
	(nil)
	127.0.0.1:6379> pfadd lan js
	(integer) 1
	127.0.0.1:6379> pfadd lan php
	(integer) 1
	127.0.0.1:6379> pfcount lan
	(integer) 2
	127.0.0.1:6379> pfadd lan php
	(integer) 0
	127.0.0.1:6379> pfcount lan
	(integer) 2
	127.0.0.1:6379> pfadd lan java python lua
	(integer) 1
	127.0.0.1:6379> pfcount lan
	(integer) 5


点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
{__SCRIPT__}