Giter Club home page Giter Club logo

credis's People

Contributors

akunzai avatar andrey-legayev avatar colinmollenhour avatar e-oz avatar efarya avatar frankdebot avatar intarstudents avatar jdp avatar kevburnsjr avatar kschroeder avatar laozhang007 avatar leeyisoft avatar lorextera avatar mangust404 avatar mhor avatar midlan avatar philetaylor avatar punkeel avatar qti3e avatar rayward avatar roydejong avatar ruudk avatar samm-git avatar szepeviktor avatar tillkruss avatar tufanbarisyildirim avatar wxiaoguang avatar xanido avatar xon avatar xtremevision avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

credis's Issues

Persistent connections broken with PHP 7.0.18

When using persistent connections, a uniqe persistence identifier is added to the remote socket specified that is fed to stream_socket_client():

$remote_socket .= '/'.$this->persistent;

In PHP 7.0.18, that breaks, due to this commit:

php/php-src@bab0b99

Any 'garbage' after the port specification now results in a 'Failed to parse address' error.

I'm not sure how to handle this, I think it's just FYI so you know what may be coming ;-)

I'm also not sure if adding something to the end of the socket specified is actually supported in PHP; I know it used to work, but it is undocumented.

Best regards,
Martijn.

scan returns false for last set of matches

redis returns the following for a small set of matches:

127.0.0.1:6379> "scan" "0" "MATCH" "table service *"
1) "0"
2) 1) "table service parms {\"server_id\":\"2\"}"
   2) "table service parms {\"server_id\":\"9\"}"

Since the cursor matches empty() for the response is set to false rather than returning the response array. I don't have an easy patch to fix this that results in compatible behavior.

This will also happen if one has multiple "pages" of data since the last one will have a cursor of "0" to let the caller know that the result has no more.

CredisException: ERR MULTI calls can not be nested

Hi Colin,

I use credis with phpredis, when invoke a unwatch after exec command, I got a CredisException saying "ERR MULTI calls can not be nested";

redisLib::instance()->watch("foo");
$reply = redisLib::instance()->multi(Redis::MULTI)
->set('foo', 1)
->set('bar', 1)
->exec();
redisLib::instance()->unwatch();

I guess we need a return after send "multi" to phpredis, otherwise we'll send second multi command to phpredis some lines after.
Please advise if I misunderstand something, thank you.

// Proxy pipeline mode to the phpredis library
if($name == 'pipeline' || $name == 'multi') {
if($this->isMulti) {
return $this;
} else {
$this->isMulti = TRUE;
$this->redisMulti = call_user_func_array(array($this->redis, $name), $args);
return $this; // need a return here
}
}

// Multi and pipeline return self for chaining
if($this->isMulti) {
call_user_func_array(array($this->redisMulti, $name), $args);
return $this;
}

A warning is produced from the Client library

Warning: Redis::expire() expects parameter 2 to be long, string given in app/code/local/Credis/Client.php on line 1132

The project has both Cm RedisSession module and Cm Cache backend class. All the components are up to date (session module, session's module abstract library, cache backend, credis library).

This is the configuration: https://codebeautify.org/xmlviewer/cb1bb1d0

I am trying to get a stack trace which will be published once I have. If any other information is needed I will try to provide.

Bug in Client.php

Line 1139 in Client.php should be:
$lastFailed = !$fwrite;

otherwise the loop never ends when a write error occurs.

no check on phpredis version

Moin Colin,
first thanks for this great library. I got into troubles today as I updated to the least recent version of credis but didn't updated phpredis. Looks like credis requires since 1.3 at least phpredis 2.2.3. Error was a call to non existing Redis::clearLastError which was added with 2.2.3.
Possible solution I could think of:

  • feature detection, checking if new methods are available
  • disabling using phpredis and fallback to credis communication plus warning
  • just throw a version missmatch exception
    Right now I don't have time to solve that my self. Just wanted to get that logged. Maybe I will provide a fix next week.

Cheers

PHPUnit alias breaking static analysis

This change: 049ccfb#diff-992f1596e0de7393cf7febdbdb934f65R4

which conditionally aliases the new PHPUnit TestCase to the old class name has broken static analysis such as typehinting and auto completion in Intellij/PHPStorm. Unfortunately these types of tools aren't intelligent enough to evaluate the conditional "only define if not already defined" so the class_alias is taking precedence over the original class definition.

Add simple failover for cache only redis usage?

Hi, when use Redis as Magento cache backend, as we don't need redis as a key-value DB, we can just do simple failover.

For example, configure two redis ip, try connected the first server, if something goes wrong, catch the exception, try second.

I've make a patch, and use it in our staging server for a while, it's seems ok.

Next release

It'd be more than welcome if you create a stable release. The last one has been created more than year ago and it lacks lot of improvements done.

Deprecated Functionality

Trying to upgrade to Magento 2.3 and getting this message: Deprecated Functionality: The each() function is deprecated. This message will be suppressed on further calls in .../vendor/colinmollenhour/cache-backend-file/File.php on line 81

Poor behavior when a sentinel's connection is garbled

In a VM; using persistent connections with the Credis_Sentinel works reasonably well until a "Unable to connect to a redis sentinel: Read operation timed out." occurs due a high cpu steal spike from the host.

Stack trace

Zend_Cache_Exception: Unable to connect to a redis sentinel: Read operation timed out. - library/Zend/Cache.php:209
#0 library/Redis/Cm/Cache/Backend/Redis.php(208): Zend_Cache::throwException('Unable to conne...', Object(CredisException))
#1 library/Zend/Cache/Backend/Redis.php(20): Cm_Cache_Backend_Redis->__construct(Array)
#2 library/Zend/Cache.php(153): Zend_Cache_Backend_Redis->__construct(Array)
#3 library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Redis', Array, false, false)

Then alternating these exceptions:

CredisException: Can' retrieve slave status - library/Redis/lib/Credis/Sentinel.php:168
#0 library/Redis/lib/Credis/Sentinel.php(185): Credis_Sentinel->createSlaveClients('mymaster')
#1 library/Redis/Cm/Cache/Backend/Redis.php(213): Credis_Sentinel->getSlaveClients('mymaster')
#2 library/Zend/Cache/Backend/Redis.php(20): Cm_Cache_Backend_Redis->__construct(Array)
#3 library/Zend/Cache.php(153): Zend_Cache_Backend_Redis->__construct(Array)
#4 library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Redis', Array, false, false)

and

ErrorException: Array to string conversion - library/Redis/lib/Credis/Client.php:300
#0 library/Redis/lib/Credis/Client.php(300): XenForo_Application::handlePhpError(8, 'Array to string...', '/var/www/sites/...', 300, Array)
#1 library/Redis/lib/Credis/Sentinel.php(139): Credis_Client->__construct(Array, Array, 1, 0, 0, NULL)
#2 library/Redis/lib/Credis/Sentinel.php(150): Credis_Sentinel->createMasterClient('mymaster')
#3 library/Redis/Cm/Cache/Backend/Redis.php(184): Credis_Sentinel->getMasterClient('mymaster')
#4 library/Zend/Cache/Backend/Redis.php(20): Cm_Cache_Backend_Redis->__construct(Array)

This lasts for a while for a minute or so till the Sentinel hangs up.

It looks like the persistent connection still has data on it, so it fails to close. Some advice recommends calling fclose() on persistent connections if they are in a broken state to force php to discard them.

I think replacing calls to $this->connected = FALSE; with $this->close(true);, using Xon@c6d6718 with a 'force' parameter.

It ensures the close() function invalidates any pipelining when in standalone mode otherwise calling close() and then then reconnect gets the Credis into a confused state.

I haven't yet deployed the latest commit on the connection_retry branch, but plan to after a little more testing.

Async write support

The client is lightweight and awesome. It would be great to have an async write feature in it.

CredisException: unknown command 'select'

I am using the following example and I am getting the error;

$sentinel = new Credis_Sentinel(new Credis_Client('127.0.0.1',26379, null, '', 2));
$cluster = $sentinel->getCluster('mymaster',10,true,true);
$cluster->set('key','value');
echo $cluster->get('key').PHP_EOL;

CredisException: unknown command 'select'

Could you please help me?

Add support for SO_KEEPALIVE

The blocking calls and long waits between commands cause Redis to get disconnected even before the server's timeout setting. To implement SO_KEEPALIVE the stream functions would all have to be replaced with lower level socket_* functions.

Magento front end lock up

Think this issue goes here

Fairly sure this is session/redis related. Front end locks up until php times out, one child thread goes 100% for maybe 5 minutes

Using an Magento EE ver. 1.14.0.1 with redis, inchoo php7 and PHP 7.0.22-0ubuntu0.16.04.1

Seen this issue twice now, clearing cookies makes it go away. Happens when there is a lot of reindexing, cache clearing, switching between admin and site

Let me know if wrong place to post or move diags needed.

I guess the Magneto Cm ( your ) stuff that came with EE that is now 2014 vintage is quite old, should I update?

Thanks for all your great work


[18-Sep-2017 07:21:20] NOTICE: fpm is running, pid 29630
[18-Sep-2017 07:21:20] NOTICE: ready to handle connections
[18-Sep-2017 07:21:20] NOTICE: systemd monitor interval set to 10000ms
[18-Sep-2017 07:23:18] WARNING: [pool www] child 29633 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 16384 bytes) in /home/ubuntu/20170821/balanceinternet-ls-travel-167c35358263/src/lib/Zend/Db/Statement/Pdo.php on line 228"
[18-Sep-2017 07:23:18] WARNING: [pool www] child 29633 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32768 bytes) in Unknown on line 0"
[18-Sep-2017 07:23:18] WARNING: [pool www] child 29633 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 24576 bytes) in Unknown on line 0"
[18-Sep-2017 07:24:52] WARNING: [pool www] child 29632 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /home/ubuntu/20170821/balanceinternet-ls-travel-167c35358263/src/lib/Credis/Client.php on line 447"
[18-Sep-2017 07:24:52] WARNING: [pool www] child 29632 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 73728 bytes) in Unknown on line 0"
[18-Sep-2017 07:24:52] WARNING: [pool www] child 29632 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /home/ubuntu/20170821/balanceinternet-ls-travel-167c35358263/src/app/code/community/Cm/RedisSession/Model/Session.php on line 565"


Tests

Hey,

I have one question connected with tests, are they valid? I'm trying to dockerize them, but for example I get segmentation fault during testPubsub and many other errors.

read error on connection

Hello, I'm having this error in a production server:

Fatal error: Uncaught exception 'RedisException' with message 'read error on connection' in /.../lib/Credis/Client.php:843

Has it happened to any of you?

Magento 2.1.5 error when trying to flush cache and setup upgrade

I get error below when trying to flush cache and running magento 2 setup upgrade command in Magento 2.1.5, credis version 1.6

Notice: fwrite(): send of 8192 bytes failed with errno=32 Broken pipe in /var/www/magento2-release/release/vendor/colinmollenhour/credis/Client.php on line 1134

Write command prone to inifite looping

Code below from write_command() is prone to infinite looping.

There are cases where fwrite can return 0 (or maybe even integers less than 0), this will cause the for loop to never end.

$commandLen = strlen($command);
for ($written = 0; $written < $commandLen; $written += $fwrite) {
    $fwrite = fwrite($this->redis, substr($command, $written));
    if ($fwrite === FALSE) {
        throw new CredisException('Failed to write entire command to stream');
    }
}

See: http://php.net/manual/en/function.fwrite.php#96951

No Support for multiple sentinels

Following "Guidelines for Redis clients with support for Redis Sentinel" ( http://redis.io/topics/sentinel-clients ):
"A Redis client supporting Sentinel can automatically discover the address of a Redis master from the master name using Redis Sentinel. So instead of a hard coded IP address and port, a client supporting Sentinel should optionally be able to take as input:
* A list of ip:port pairs pointing to known Sentinel instances."

This sentinel client accepts only one client.

Because of that this sentinel client will not be able to find a redis master if selected sentinel fails:

"Step 1: connecting to the first Sentinel

The client should iterate the list of Sentinel addresses. For every address it should try to connect to the Sentinel, using a short timeout (in the order of a few hundreds of milliseconds). On errors or timeouts the next Sentinel address should be tried.

If all the Sentinel addresses were tried without success, an error should be returned to the client."

Do not throw an exception when calling forceStandalone and standalone is already the case

In #46 (comment) it was suggested to use sentinel with multiple servers for example like this:

function getSentinel($sentinelHosts) {
    foreach (explode(',',$sentinelHosts) as $sentinelHost) { // Sort or randomize as appropriate
        try {
            $client = new Credis_Client($sentinelHost, NULL, 0.1);
            $client->connect();
            return new Credis_Sentinel($client);
        } catch (CredisException $e) {}
    }
    throw new Exception("Could not connect to a Redis sentinel.");
}

I tested it and it my tests fail with this implementation. Problem is that Sentinel calls $client->forceStandalone() in https://github.com/colinmollenhour/credis/blob/1.6/Sentinel.php#L53 but the client is already connected causing it to trigger an exception in https://github.com/colinmollenhour/credis/blob/1.6/Client.php#L361 Cannot force Credis_Client to use standalone PHP driver after a connection has already been established.

Instead in the forceStandalone method of the client it should be checked in the beginning whether standalone is already the case and if so, return immediately:

    public function forceStandalone()
    {
        if ($this->standalone) {
            return $this;
        }

        if($this->connected) {
        ...

Client.php errors with Redis testing 10000 concurrent users

Hi team,

I've been using this library but since I'm testing with 10000 concurrent users, is returning the following error:

CredisException: Uncaught exception 'CredisException' with message 'Connection to Redis failed after 2 failures.' in /var/www/vhosts/colmapp.com.do/httpdocs/lib/Credis/Client.php:443

I'm using redis as standalone server on a 15GB RAM cloud server and looks without any issue.
Here is the configuration:

grep -v '#' /etc/redis.conf
protected-mode yes
port 6379
tcp-backlog 65536
unixsocket /tmp/redis.sock
unixsocketperm 777
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis/redis.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
maxclients 50000
maxmemory 11947mb
maxmemory-policy allkeys-lru
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 15000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

Here is the redis.log

            _._                                                  
         _.-``__ ''-._                                             
    _.-``    `.  `_.  ''-._           Redis 3.2.11 (00000000/0) 64 bit
.-`` .-```.  ```\/    _.,_ ''-._                                   
(    '      ,       .-`  | `,    )     Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 4606
`-._    `-._  `-./  _.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                  
|    `-._`-._        _.-'_.-'    |           http://redis.io        
`-._    `-._`-.__.-'_.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                  
|    `-._`-._        _.-'_.-'    |                                  
`-._    `-._`-.__.-'_.-'    _.-'                                   
    `-._    `-.__.-'    _.-'                                       
        `-._        _.-'                                           
            `-.__.-'                                               

4606:M 24 Apr 20:57:18.787 # WARNING: The TCP backlog setting of 65536 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 10240.
4606:M 24 Apr 20:57:18.787 # Server started, Redis version 3.2.11
4606:M 24 Apr 20:57:18.788 * The server is now ready to accept connections on port 6379
4606:M 24 Apr 20:57:18.788 * The server is now ready to accept connections at /tmp/redis.sock

I ignore the warning due we are using sockets.

Not sure what is the real problem is.

Please review the following commit

Hi Colin

I submitted a pull request on Cm_Cache_Backend_Redis some time ago. It featured multi-server support, but it was declined because Credis needed some work.

I believe I did some of the work. It surely ain't perfect yet, but it's a start. Please review the following commit: ThijsFeryn@ff3c524

This separate branch has full Sentinel support and built-in read/write splitting for Credis_Cluster. The Sentinel class uses Credis_Cluster to abstract the read and write nodes.

I'd appreciate your feedback, which I will use to update this until it's ready for a pull request. If you want to test it, just run examples/start.sh and then run test.php. The Sentinel is configured to do an autofailover after 5 seconds.

Bear in mind that Sentinel actually overwrites Redis configs.

Hope you like it. I'm very much willing to make this work and once Credis is up to a certain level of quality, I can start including these clustering features in Cm_Cache_Backend_Redis.

Cheers
Thijs

Connect retries not attempted with phpredis

Environment:

Steps to reproduce:

  1. Make sure the Redis server 127.0.0.1:6379 is unresponsive (or not running at all)
  2. Execute the following test script:
$redis = new Credis_Client('127.0.0.1', 6379, $timeout = 2.5);
$redis->setMaxConnectRetries(3);
$redis->connect();

Expected result:

  • Three unsuccessful connection attempts
  • Exception CredisException with the following message is thrown:

Connection to Redis failed after 3 failures.

Actual result:

  • One unsuccessful connection attempt
  • Error E_WARNING with the following message is triggered:

Redis::connect(): connect() failed: Connection timed out

wrong issue

Posted this with the wrong github user, my bad.

Cluster MGET hash key support

Hi,

When trying to read from a cluster using the MGET command, the \Credis_Cluster::hash($key) method - which md5's the key expects a string, but in case of MGET it receives an array of keys - fails with an E_WARNING.
md5() expects parameter 1 to be string, array given on line 238 in vendor/colinmollenhour/credis/Cluster.php
We use the php-redis client.

Please add an is_array($key) check and then compact the key to a string.

Regards,
L

Handle zrangebyscore options in standalone mode

In standalone mode, this code :

$credis->zrangebyscore('delayed_queue_schedule', '-inf', '+inf', array('limit' => array(0, 1)));

throws :

PHP Warning:  strlen() expects parameter 1 to be string, array given in [...]/vendors/colinmollenhour/credis/Client.php on line 111
PHP Notice:  Array to string conversion in [...]/vendors/colinmollenhour/credis/Client.php on line 1111

And redis monitor shows :

1426601217.405207 "zrangebyscore" "delayed_queue_schedule" "-inf" "+inf" ""

Redis::expire() expects parameter 2 to be integer, string give @ M1.9.4.x. and PHP 7.2

Redis::expire() expects parameter 2 to be integer, string give @ M1.9.4.x. and PHP 7.2

Error in logging:
Warning: Redis::expire() expects parameter 2 to be integer, string given in /var/www/html/shirts/public_html/app/code/local/Credis/Client.php on line 114

I remember we did/kinda tackled this before .. but now it is back dont know yet how or why. And not sure if this is related to credis or the method storing the data

Cluster with failover?

Is it possible to configure the library to allow failovers when a alias is unreachable? My master server is really just a HAProxy endpoint that is configured to check the health checks of my slave instances and promote a new master when one fails. See thread here for details: https://karlstoney.com/2015/07/23/redis-sentinel-behind-haproxy/

Here is my current configuration:

        $this->redis = new \Credis_Cluster(
            [
                [
                    'host' => '10.10.10.1', // HAProxy checking Sentinel tcp health checks and promoting new master if failure occurs
                    'port' => 26379,
                    'alias' => 'master',
                    'master' => true,
                    'password' => 'something',
                ],
                [
                    'host' => '10.10.10.2',
                    'port' => 6379,
                    'alias' => 'slave-1',
                    'password' => 'something',
                ],
                [
                    'host' => '10.10.10.3',
                    'port' => 6379,
                    'alias' => 'slave-2',
                    'password' => 'something',
                ],
                [
                    'host' => '10.10.10.4',
                    'port' => 6379,
                    'alias' => 'slave-3',
                    'password' => 'something',
                ],
                [
                    'host' => '10.10.10.5',
                    'port' => 6379,
                    'alias' => 'slave-4',
                    'password' => 'something',
                ],
            ]
        );

It would be nice if the alias servers could failover, right now they throw a CredisException if they are unreachable.

I see phpredis has a few options that might work, but I'm wondering if you have tried them:

->setOption(RedisCluster::OPT_SLAVE_FAILOVER, RedisCluster::FAILOVER_DISTRIBUTE);

Thanks

Connection Retries: Exponential Backoff

It would be nice to be able to do exponential backoff on the automatic connection retries. In my experience if it fails the first time, redoing it immediately will usually fail as well. If you add a small delay (ie: 200ms) it has a much higher chance of success.

Example:

$this->connectFailures++;
if ($this->connectFailures <= $this->maxConnectRetries) {
    $timeout = $this->connectionBackoff;
    for($i = 1; $i < $this->connectFailures; $i++) {
        $timeout = $timeout * 2;
    }
    usleep($timeout);
    return $this->connect();
}

1st Retry: 100ms
2nd Retry: 200ms
3d Retry: 400ms
etc...

Pipeline returns different result format for HMGET in standalone/redis extension mode

When executing HMGET over a pipeline, the result is different in standalone and Redis extension mode. While a simple HMGET always returns an array with numeric indexes in both standalone and Redis extension mode, the HMGET over a pipeline with the Redis extension enabled returns an array indexed by field name instead. See the following test case (the myhash has is the one from https://redis.io/commands/hmset):

<?php

require_once __DIR__ . '/vendor/autoload.php';

$id     = 'myhash';
$fields = ['field1', 'field2'];

$redis = new Credis_Client('127.0.0.1', 6379, null, '', 13);

if (extension_loaded('redis')) {
    echo "The Redis extension is loaded\n\n";
} else {
    echo "The Redis extension is not loaded\n\n";
}

// simple hMGet
echo "Simple HMGET\n";
var_dump($redis->hMGet($id, $fields));
echo "\n";

// pipeline HMGET
echo "Pipeline HMGET\n";

$pipeline = $redis->pipeline()->multi();
$pipeline->hMGet($id, $fields);
var_dump($pipeline->exec()[0]);

Without Redis extension:

The Redis extension is not loaded

Simple HMGET
/home/vagrant/credis-index/credis-test.php:18:
array(2) {
  [0] =>
  string(5) "Hello"
  [1] =>
  string(5) "World"
}

Pipeline HMGET
/home/vagrant/credis-index/credis-test.php:26:
array(2) {
  [0] =>
  string(5) "Hello"
  [1] =>
  string(5) "World"
}

With Redis extension (see Pipeline HMGET):

The Redis extension is loaded

Simple HMGET
/home/vagrant/credis-index/credis-test.php:18:
array(2) {
  [0] =>
  string(5) "Hello"
  [1] =>
  string(5) "World"
}

Pipeline HMGET
/home/vagrant/credis-index/credis-test.php:26:
array(2) {
  'field1' =>
  string(5) "Hello"
  'field2' =>
  string(5) "World"
}

PHP version: PHP 7.1.6
Redis extension version: 3.1.2
Redis version: 3.2.8
colinmollenhour/credis: 1.8.2

Deprecated Functionality

Trying to upgrade to Magento 2.3 and getting this message: Deprecated Functionality: The each() function is deprecated. This message will be suppressed on further calls in .../vendor/colinmollenhour/cache-backend-file/File.php on line 81

Random Magento exception: Failed to write entire command to stream from Credis/Client.php

Using Redis and Credis Client.php library without phpredis installed and Magento 1.9 issues random exception: Failed to write entire command to stream";i:1;s:3418:"#0 /path-to-magento-folder/lib/Credis/Client.php(537): Credis_Client->write_command('*2??$6??select?...').
This event is random and causes the site to show ugly Magento Exception report page. After the reload the page is shown, but the error appears on random page every now and then.

I managed to install and activate phpredis and this problem no longer exists, so the problem is probably just with the PHP standalone version.

Write operations skipped sometimes

I'm having a problem with this Redis Client, I am using it for storing user sessions and the sessions most of the time dont get written to database, is it just me or this bug has affected others too?

Pipeline called twice

Hey,

I'm running into an issue when I'm using credis with some PHP instrumentation (specifically, we're using TraceView). Hoping you can help troubleshoot. We are using your Cm_RedisSesion Magento module, which leverages this lib.

The problem we are seeing is within the __call() method when calling a pipeline.

When we call the credis pipeline() function, in the call function, the internal redis->pipeline call is happening twice without closing the connection. At the beginning, $this->isMulti is set to false, so call_user_func_array is calling pipeline.

    // Proxy pipeline mode to the phpredis library
    if($name == 'pipeline' || $name == 'multi') {
        if($this->isMulti) {
            return $this;
        } else {
            $this->isMulti = TRUE;
            $this->redisMulti = call_user_func_array(array($this->redis, $name), $args); 
        }
    }

Then the code continues (there is no return after call_user_func_array), and it later executes this:

    // Multi and pipeline return self for chaining
    if($this->isMulti) {
        call_user_func_array(array($this->redisMulti, $name), $args);
        return $this;
    }

Since it's making two calls to pipeline in one session, it's breaking our instrumentation (not sure on exactly why, I don't have a lot of details from TraceView except that they said if you invoke a pipeline without calling 'exec()' on it, leaving it open, that there's an issue, and exec() is called after __call() is invoked).

Our immediate resolution is going to be adding a return $this after the first call to pipeline. But I wanted to run this by you to see if you think this will be problematic. Let me know if I can provide more details.

stream_socket_client() - PHP 7.0.14 - Connection timed out

Hi guys!, I have a problem and I can't understand what is due, can you help me please?

The problem is that for some reason, sometimes, I get the following message:
stream_socket_client(): unable to connect to tcp://10.1.101.37:6379 (Connection timed out) in /home/user/app/vendor/colinmollenhour/credis/Client.php:428,
and I don't know why?

Ubuntu version: 14.04
PHP Version: 7.0.14. I'm not using persistent connections, Will it have something to do?

The maxclients in redis, is configured in 10 thousand and the maximum that I have of connections, is 3 thousand, therefore I understand that it is not a matter of which I am left without available connections.

Any idea?

[~FEATURE-REQUEST] HHVM Support - lz4/snappy

HHVM also have snappy and lz4 support.
but there do not use the php method.

Example:
PHP: lz4_compress
HHVM: lz4compress
PHP: lz4_uncompress
HHVM: lz4uncompress


PHP: snappy_compress
HHVM: sncompress
PHP: snappy_uncompress
HHVM: snappy_compress

lzf does not supported by HHVM
and gzip is to slow^

and workaround is to create this method is there does not exists, like

if(!function_exists('lz4_compress') && function_exists('lz4compress'))
{
    function lz4_compress($data, $high = false, $extra = null)
    {
        return lz4compress($data);
    }
}

may some one have a better soultion on this :/

Information: facebook/hhvm#2518

Cannot modify header information - headers already sent

Warning: Cannot modify header information - headers already sent by (output started at /srv/public_html/vendor/colinmollenhour/credis/Client.php:444) in /srv/public_html/vendor/magento/framework/Stdlib/Cookie/PhpCookieManager.php on line 148

How to solve this issue?

getSelectedDb not working on Cluster auto-selectable Client

$oSentinel = new \Credis_Sentinel(new \Credis_Client($host, $port));

$oRedisInstance = $oSentinel->getCluster($sSentinelName, $db);

$oRedisInstance->getSelectedDb() // -- will throw error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Redis' does not have a method 'getselecteddb' in .../vendor/colinmollenhour/credis/Client.php on line 1047

But, when you create standalone Client - it works find.
$oRedisInstance = new \Credis_Client($host, $port);
$oRedisInstance->select($db);
$oRedisInstance->getSelectedDb() // -- works find

It's because Cluster->__call takes Client and run __call on it, which NOT try check if method present and trying to run Redis command.
Please, add somewhere in __call something like that:
if (method_exists($this,$name) {
return $this->{$name}();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.