Skip to content

Commit 5008702

Browse files
Merge branch '4.1'
* 4.1: [DoctrineBridge] support __toString as documented for UniqueEntityValidator [travis] enable Redis cluster [Cache] enable Memcached::OPT_TCP_NODELAY to fix perf of misses fix data mapper return type in docblock fix type error handling when writing values
2 parents 5fba7ca + 0e4f041 commit 5008702

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

Store/RedisStore.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ public function save(Key $key)
5454
$script = '
5555
if redis.call("GET", KEYS[1]) == ARGV[1] then
5656
return redis.call("PEXPIRE", KEYS[1], ARGV[2])
57+
elseif redis.call("SET", KEYS[1], ARGV[1], "NX", "PX", ARGV[2]) then
58+
return 1
5759
else
58-
return redis.call("set", KEYS[1], ARGV[1], "NX", "PX", ARGV[2])
60+
return 0
5961
end
6062
';
6163

@@ -140,7 +142,7 @@ private function evaluate(string $script, string $resource, array $args)
140142
return \call_user_func_array(array($this->redis, 'eval'), array_merge(array($script, 1, $resource), $args));
141143
}
142144

143-
throw new InvalidArgumentException(sprintf('%s() expects been initialized with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
145+
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
144146
}
145147

146148
/**

Tests/Store/RedisClusterStoreTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Tests\Store;
13+
14+
/**
15+
* @author Jérémy Derussé <[email protected]>
16+
*
17+
* @requires extension redis
18+
*/
19+
class RedisClusterStoreTest extends AbstractRedisStoreTest
20+
{
21+
public static function setupBeforeClass()
22+
{
23+
if (!class_exists('RedisCluster')) {
24+
self::markTestSkipped('The RedisCluster class is required.');
25+
}
26+
if (!getenv('REDIS_CLUSTER_HOSTS')) {
27+
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
28+
}
29+
}
30+
31+
protected function getRedisConnection()
32+
{
33+
return new \RedisCluster(null, explode(' ', getenv('REDIS_CLUSTER_HOSTS')));
34+
}
35+
}

0 commit comments

Comments
 (0)