phpredis

php 安装redis扩展

巧了我就是萌 提交于 2020-03-10 17:17:21
第一 下载:git上下载redis的扩展包 git clone https://github.com/nicolasff/phpredis 第二 挂载: 在shell中输入 phpize 【查看适合的版本信息】 ./configure 编译 【 phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块 】 注意:(phpize 如果包含多个php,必须指定位置) cuihuan:phpredis cuixiaohuan$ phpize Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. 报错的话需要安装:brew install autoconf [phpize 报错] 否则没有phpize [work@cuixiaozhuai phpredis]$ phpize Configuring for: PHP Api Version:

redis报错:read error on connection的两种原因分析

左心房为你撑大大i 提交于 2020-03-09 18:18:40
最近线上php模块偶现 read error on connection;具体报错日志如下 Uncaught exception 'RedisException' with message ' read error on connection' 通过分析和学习之后,发现两种原因可能导致 phpredis 返回 'read error on connection': 执行超时 使用已经断开的连接 下面将对这两种情况进行具体的分析。 一、执行超时 超时又可以分两种情况:一种是客户端设置的超时时间过短导致的;另外一种是客户端未设置超时时间,但是服务端执行时间超过了默认超时时间设置。 1.1 模拟复现 1.1.1 客户端设置超时时间过短 测试环境的 get 操作 执行耗时约 0.1ms 数量级;因此客户端设置执行超时时间为0.01ms, 测试脚本如下: <?php $rds = new Redis(); try { $ret = $rds->pconnect( "127.0.0.1" , 6390 ); if ($ret == false ) { echo "Connect return false" ; exit ; } //设置超时时间为 0.1ms $rds->setOption( 3 , 0.0001 ); $rds->get( "aa" ); } catch (

thinkphp5结合centos安装phpredis扩展

喜欢而已 提交于 2019-12-25 14:54:26
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 坑! 首先说一下,安装这个需要一些前置条件, 如果不安装php-devel就不会有phpize和php-config,接下去的步骤也就没办法进行了,或者你有别的的办法也行 phpredis 下载地址为: https://github.com/phpredis/phpredis/releases 安装可以用 yum list |grep php-devel* 查看相关版本 并安装, 接下来安装phpredis wget https://github.com/phpredis/phpredis/archive/5.5.1.tar.gz(这里的版本是我的,请自行选择版本) cd phpredis-5.5.1 # 进入 phpredis 目录 /usr/bin/phpize # (不知道位置的可以whereis phpize 查看位置) 如果出现上面的步骤,多半是php-devel包和你自己的php版本不符合,需要重新安装php-devel, 运行: yum install php-devel, 如果出现上面的错误提示,建议检查当前linux的php版本, 我这里是7.2的php版本,所以运行:yum install php72w-devel,提示安装成功, 接着运行:/usr/bin/phpize,

Error in implementing message queue using redis, error in using BLPOP

人盡茶涼 提交于 2019-12-23 01:28:09
问题 I am trying to build a message queue using Redis. Whenever client sends new data, they are added to a list. Here is the code for it $client->lPush("my_queue", $data); Now there is a separate script slave.php which pops the newly arrived data and process it. The code for slave.php while (true) { list($queue, $message) = $client->brPop(["my_queue"], 0); /* Logic to process the data */ } I have modified the apache startup script so that slave.php should start & stop with apache. It works well.

phpredis extension doesn't work, unable to load 'redis.so'

血红的双手。 提交于 2019-12-22 04:18:08
问题 I installed nginx, php, php-fpm, php-pecl-redis by yum. All of them work but the last one. When I run /usr/sbin/php-fpm , I got this: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/redis.so' - /usr/lib/php/modules/redis.so: undefined symbol: igbinary_unserialize in Unknown on line 0 I don't know what "igbnary_unserialize" means and how to fix it. I checked the redis.so file under right path. I add extension=redis.so to "php.ini" php version: 5.3.3 phpredis

php-redis - Is there a way to store PHP object in Redis without serializing it?

流过昼夜 提交于 2019-12-21 04:13:33
问题 I am trying to store user' request URL as the key and a PHP object corresponding to that key as the value in Redis. I tried the following: $redisClient = new Redis(); $redisClient->connect('localhost', 6379); $redisClient->set($_SERVER['REQUEST_URI'], $this->page); $redisTest = $redisClient->get($_SERVER['REQUEST_URI']); var_dump($redisTest); However, with this code the value of the URL key that is being stored in Redis is type of string with the value equal to 'Object' instead of the actual

Redis how to store associative array? Set or Hash or List?

有些话、适合烂在心里 提交于 2019-12-20 08:10:59
问题 I'm a bit confused with all the available storing options of Redis. I want to do something simple and I don't want to over engineer it. I'm working with phpredis and Redis v2.8.6 . I have this simple associative array that I need to store. I also need to be able to retrieve an item by its key and loop over all the items. $a = array( '12345' => array( 'name' => 'Post A', 'val2' => 'blah blah', 'val3' => 'blah blah blah', ), '54321' => array( 'name' => 'Post B', 'val2' => 'blah blah', 'val3' =>

redis.so module is not loaded

青春壹個敷衍的年華 提交于 2019-12-13 20:11:01
问题 I have an EC2 instance on Amazon Web Services and, in the same VPC there's also an instance of ElastiCache (Redis). My EC2 instance have installed Amazon Linux AMI 2015.09. I have also configured it to work with mpm_worker_module and not prefork. The configuration is correctly working and I can access pages from my browser. I have then installed redis client, and the redis-cli command is perfectly working from ssh. I have then installed phpredis (https://github.com/nicolasff/phpredis/zipball

How to delete multiple redis keys with the same pattern in PHP using phpredis?

久未见 提交于 2019-12-10 16:29:28
问题 By using phpredis, I have saved some data in pagination like this: review/itemA/1 review/itemA/2 where 1 and 2 are page numbers. I read in the document that you can use wildcards to retrieve multiple keys. $allKeys = $redis->keys('*'); // all keys will match this. $keyWithUserPrefix = $redis->keys('user*'); But can I delete all the old keys using wildcards as well when someone has posted a new review? Can I do something like: $redis->delete('review/itemA/*'); // or $redis->delete('review

Installing phpredis on osx with pecl

帅比萌擦擦* 提交于 2019-12-10 16:23:29
问题 I have some trouble installing phpredis on my Mac OSX Maverics. I do have redis server installed and running. I used sudo pecl install redis to install phpredis. Now when I was doing that, this what came up: running: make /bin/sh /private/tmp/pear/temp/pear-build-rootEsw0Wz/redis-2.2.4/libtool --mode=compile cc -I. -I/private/tmp/pear/temp/redis -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-rootEsw0Wz/redis-2.2.4/include -I/private/tmp/pear/temp/pear-build-rootEsw0Wz/redis-2.2.4/main -I