1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 12:17:35 +02:00

Switch back to using rpush

Switches back to rpush to keep list order consistent with non capped
collections
This commit is contained in:
Matt Wells
2015-07-13 19:40:51 +01:00
parent ae2b2d0de1
commit 12711d133a
2 changed files with 8 additions and 8 deletions

View File

@@ -75,15 +75,15 @@ class RedisHandler extends AbstractProcessingHandler
{ {
if($this->redisClient instanceof \Redis) { if($this->redisClient instanceof \Redis) {
$this->redisClient->multi() $this->redisClient->multi()
->lpush($this->redisKey, $record["formatted"]) ->rpush($this->redisKey, $record["formatted"])
->ltrim($this->redisKey, 0, $this->capSize) ->ltrim($this->redisKey, -$this->capSize, -1)
->execute(); ->execute();
} else { } else {
$redisKey = $this->redisKey; $redisKey = $this->redisKey;
$capSize = $this->capSize; $capSize = $this->capSize;
$this->redisClient->transaction(function($tx) use($record, $redisKey, $capSize) { $this->redisClient->transaction(function($tx) use($record, $redisKey, $capSize) {
$tx->lpush($redisKey, $record["formatted"]); $tx->rpush($redisKey, $record["formatted"]);
$tx->ltrim($redisKey, 0, $capSize); $tx->ltrim($redisKey, -$capSize, -1);
}); });
} }
} }

View File

@@ -71,7 +71,7 @@ class RedisHandlerTest extends TestCase
public function testRedisHandleCapped() public function testRedisHandleCapped()
{ {
$redis = $this->getMock('Redis', array('multi', 'lpush', 'ltrim', 'execute')); $redis = $this->getMock('Redis', array('multi', 'rpush', 'ltrim', 'execute'));
// Redis uses multi // Redis uses multi
$redis->expects($this->once()) $redis->expects($this->once())
@@ -79,7 +79,7 @@ class RedisHandlerTest extends TestCase
->will($this->returnSelf()); ->will($this->returnSelf());
$redis->expects($this->once()) $redis->expects($this->once())
->method('lpush') ->method('rpush')
->will($this->returnSelf()); ->will($this->returnSelf());
$redis->expects($this->once()) $redis->expects($this->once())
@@ -101,10 +101,10 @@ class RedisHandlerTest extends TestCase
{ {
$redis = $this->getMock('Predis\Client', array('transaction')); $redis = $this->getMock('Predis\Client', array('transaction'));
$redisTransaction = $this->getMock('Predis\Client', array('lpush', 'ltrim')); $redisTransaction = $this->getMock('Predis\Client', array('rpush', 'ltrim'));
$redisTransaction->expects($this->once()) $redisTransaction->expects($this->once())
->method('lpush') ->method('rpush')
->will($this->returnSelf()); ->will($this->returnSelf());
$redisTransaction->expects($this->once()) $redisTransaction->expects($this->once())