|
20 | 20 |
|
21 | 21 | $app = new LockApplication();
|
22 | 22 |
|
23 |
| -$redisConn = new \Predis\Client( |
24 |
| - 'tcp://redis:6379' |
25 |
| -); |
| 23 | +$redisConns = []; |
| 24 | +$redisStores = []; |
26 | 25 |
|
27 |
| -$redisConn2 = new \Predis\Client( |
28 |
| - 'tcp://redis2:6379' |
29 |
| -); |
| 26 | +$redisConn = new \Predis\Client('tcp://redis:6379'); |
| 27 | +try { |
| 28 | + $redisConn->connect(); |
| 29 | + $redisStores[] = new RedisStore($redisConn); |
| 30 | +} catch (\Exception $e) {} |
| 31 | + |
| 32 | +$redisConn2 = new \Predis\Client('tcp://redis2:6379'); |
| 33 | +try { |
| 34 | + $redisConn2->connect(); |
| 35 | + $redisStores[] = new RedisStore($redisConn2); |
| 36 | +} catch (\Exception $e) {} |
| 37 | + |
| 38 | +$redisConn3 = new \Predis\Client('tcp://redis3:6379'); |
| 39 | +try { |
| 40 | + $redisConn3->connect(); |
| 41 | + $redisStores[] = new RedisStore($redisConn3); |
| 42 | +} catch (\Exception $e) {} |
30 | 43 |
|
31 |
| -$redisConn3 = new \Predis\Client( |
32 |
| - 'tcp://redis3:6379' |
33 |
| -); |
34 | 44 |
|
35 | 45 | $memcachedConn = new \Memcached;
|
36 | 46 | $memcachedConn->addServer('memcached', 11211);
|
37 | 47 |
|
38 | 48 | $app->addStore('flock', new FlockStore(sys_get_temp_dir()));
|
39 | 49 | $app->addStore('semaphore', new SemaphoreStore());
|
40 |
| -$app->addStore('redis', new RetryTillSaveStore(new RedisStore($redisConn))); |
| 50 | + |
| 51 | +$app->addStore('redis', new RetryTillSaveStore( |
| 52 | + new RedisStore($redisConn) |
| 53 | +)); |
| 54 | + |
41 | 55 | $app->addStore('memcached', new RetryTillSaveStore(new MemcachedStore($memcachedConn)));
|
42 |
| -$app->addStore('combined', new RetryTillSaveStore(new CombinedStore([ |
43 |
| - new RedisStore($redisConn), |
44 |
| - new RedisStore($redisConn2), |
45 |
| - new RedisStore($redisConn3) |
46 |
| -], new ConsensusStrategy()))); |
| 56 | +$app->addStore('combined', new RetryTillSaveStore(new CombinedStore( |
| 57 | + $redisStores, |
| 58 | + new ConsensusStrategy()) |
| 59 | +)); |
47 | 60 |
|
48 | 61 | $app->command('resource:reset [resource]', function ($output, $factory, $input) {
|
49 | 62 | $resourceName = $input->getArgument('resource');
|
|
0 commit comments