phpredis

Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away'

ε祈祈猫儿з 提交于 2019-12-07 14:07:43
问题 One of my application suddenly started to give error: Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away' in /var/www/_slim/_core/system/generator.001.php:133 Stack trace: #0 /var/www/_slim/_core/system/generator.001.php(133): Redis->auth('77B1BFFBC0378DF...') #1 /var/www/_slim/_core/system/generator.007.php(144): Generator001->r6_redis_start('R') #2 /var/www/_slim/_core/system/generator.007.php(26): Generator007->HarvestRedis() #3 /var/www/_slim/_core

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

五迷三道 提交于 2019-12-06 17:52:29
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. But after waiting for few minutes the brPop stops listening with the error message like this : Uncaught

Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away'

空扰寡人 提交于 2019-12-05 20:13:56
One of my application suddenly started to give error: Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away' in /var/www/_slim/_core/system/generator.001.php:133 Stack trace: #0 /var/www/_slim/_core/system/generator.001.php(133): Redis->auth('77B1BFFBC0378DF...') #1 /var/www/_slim/_core/system/generator.007.php(144): Generator001->r6_redis_start('R') #2 /var/www/_slim/_core/system/generator.007.php(26): Generator007->HarvestRedis() #3 /var/www/_slim/_core/system/generator.shopping.php(14): Generator007->Generator007() #4 /var/www/_slim/_core/system/generator

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

霸气de小男生 提交于 2019-12-05 06:21:19
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 version: 2.2.7 I had the same issue. I'm on Ubuntu 16.04 LTS. Running sudo apt-get install php-igbinary

docker php-fpm 拓展安装

為{幸葍}努か 提交于 2019-12-04 16:57:27
1. PHP 源码 为了保证 Docker 镜像尽量小,PHP 的源文件是以压缩包的形式存在镜像中,官方提供了 docker-php-source 快捷脚本,用于对源文件压缩包的解压(extract)及解压后的文件进行删除(delete)的操作。 示例: FROM php:7.1-apache RUN docker-php-source extract \ # 此处开始执行你需要的操作 \ && docker-php-source delete 注意:一定要记得删除,否则解压出来的文件会大大增加镜像的文件大小。 2. 安装扩展 2.1. 核心扩展 这里主要用到的是官方提供的 docker-php-ext-configure 和 docker-php-ext-install 快捷脚本,如下 FROM php:7.1-fpm RUN apt-get update \ # 相关依赖必须手动安装 && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng-dev \ # 安装扩展 && docker-php-ext-install -j$(nproc) iconv mcrypt \ # 如果安装的扩展需要自定义配置时 && docker-php-ext-configure

php-redis函数帮助手册_consturct_connect_open_pconnect...

僤鯓⒐⒋嵵緔 提交于 2019-12-03 21:36:13
Redis::__construct Description Creates a Redis client 创建一个Redis客户端 Example $redis = new Redis(); connect, open Description Connects to a Redis instance.( 连接到一个Redis实例) Parameters host : string. can be a host, or the path to a unix domain socket host:字符串类型 可以使一个HOST IP或者是一个UNIX DOMAIN SOCKET的路径 port : int, optional port:整数型,Redis的运行端口 timeout : float, value in seconds (optional, default is 0 meaning unlimited) timeout:浮点型,连接的市场,单位是秒,默认为0即连接没有时间限制 Return Value BOOL : TRUE on success, FALSE on error. Example $redis->connect('127.0.0.1', 6379); $redis->connect('127.0.0.1'); // port 6379 by default

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

痴心易碎 提交于 2019-12-03 12:42:10
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 PHP object. Is there a way to store a PHP object without serializing it? Aliweb As you can see in Redis

Redis BitMap介绍及使用

核能气质少年 提交于 2019-12-01 19:47:50
Redis允许使用二进制数据的Key(binary keys) 和二进制数据的Value(binary values)。Bitmap就是二进制数据的value。Redis的 setbit(key, offset, value)操作对指定的key的value的指定偏移(offset)的位置1或0,时间复杂度是O(1)。 Redis BitMaps的操作命令: SETBIT key offset value 对指定的key的value的指定偏移(offset)的位置1或0 GETBIT key offset 获取offset设置的值,未设置过默认返回0 BITCOUNT key [start end] 统计指定key位置为1的数量(区间统计不建议使用,bitcount用的是byte来计算位数,其他setbit和getbit用的是bit,详见: http://blog.linuxphp.org/archives/1627/ ) BITOP operation destkey key [key ...] Bit运算,BITOP 支持四种表达式运算: AND(交集), OR(并集), XOR(异或) 和NOT(取非), 用法如下: BITOP AND destkey srckey1 srckey2 srckey3 ... srckeyN BITOP OR destkey srckey1

php使用redis作为session存储

梦想与她 提交于 2019-12-01 19:01:28
PHP使用redis作为session存储方式 phpredis安装 phpredis的首页: https://github.com/phpredis/phpredis#installation 解压代码 执行以下命令 phpize ./configure make && make install 更改php配置 打开php配置文件,添加extension=redis.so php配置session存储方式为redis 有两种方式可以做到: 在配置文件中修改为以下内容 session.save_handler = redis; session.save_path = " tcp://hostname:6379 "; 在代码中添加以下代码 ini_set("session.save_handler", "redis"); ini_set("session.save_path", " tcp://hostname:6379 "); 测试是否成功 session_start(); $_SESSION['test_key'] = 'this is session content!'; echo $_SESSION['test_key']; echo ' '; $redis = new redis(); $redis->connect('127.0.0.1', 6379); /

How do you search for keys with a value? For example get all KEYS where the value is “somevalue”

試著忘記壹切 提交于 2019-11-30 16:07:39
redis> SMEMBERS CO:1:A 1) "1" 2) "2" redis> SMEMBERS CO:2:A 1) "1" 2) "5" 3) "6" redis> SMEMBERS CO:3:A 1) "5" redis> SMEMBERS CO:4:A 1) "1" Now I want to find the keys where the value 1 exist If I search with the values 1 then the result keys will be CO:1:A, CO:2:A and CO:4:A How to get This? Redis is not a relational database. You need to anticipate this access path, and maintain a reverse index. # This is your index SADD CO:1:A 1 2 SADD CO:2:A 1 5 6 SADD CO:3:A 5 SADD CO:4:A 1 # Here is the reverse index SADD REV:1 1 2 4 SADD REV:2 1 SADD REV:5 2 3 SADD REV:6 2 Now you can query in reverse