|
8 | 8 |
|
9 | 9 | class Redis { |
10 | 10 |
|
| 11 | + /** |
| 12 | + * Create a new Redis instance. If passed sufficient information in the |
| 13 | + * options array it is also possible to connect to an instance at the same |
| 14 | + * time. |
| 15 | + * |
| 16 | + * @see Redis::connect() |
| 17 | + * @see https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ |
| 18 | + * |
| 19 | + * Following is an example of an options array with the supported |
| 20 | + * configuration values. Note that all of these values are optional, and you |
| 21 | + * can instead connect to Redis via PhpRedis' connect() method. |
| 22 | + * |
| 23 | + * <code> |
| 24 | + * <?php |
| 25 | + * $options = [ |
| 26 | + * 'host' => 'localhost', |
| 27 | + * 'port' => 6379, |
| 28 | + * 'readTimeout' => 2.5, |
| 29 | + * 'connectTimeout' => 2.5, |
| 30 | + * 'persistent' => true, |
| 31 | + * |
| 32 | + * // Valid formats: NULL, ['user', 'pass'], 'pass', or ['pass'] |
| 33 | + * 'auth' => ['phpredis', 'phpredis'], |
| 34 | + * |
| 35 | + * // See PHP stream options for valid SSL configuration settings. |
| 36 | + * 'ssl' => ['verify_peer' => false], |
| 37 | + * |
| 38 | + * // How quickly to retry a connection after we time out or it closes. |
| 39 | + * // Note that this setting is overridden by 'backoff' strategies. |
| 40 | + * 'retryInterval' => 100, |
| 41 | + * |
| 42 | + * // Which backoff algorithm to use. 'decorrelated jitter' is |
| 43 | + * // likely the best one for most solutiona, but there are many |
| 44 | + * // to choose from: |
| 45 | + * // REDIS_BACKOFF_ALGORITHM_DEFAULT |
| 46 | + * // REDIS_BACKOFF_ALGORITHM_CONSTANT |
| 47 | + * // REDIS_BACKOFF_ALGORITHM_UNIFORM |
| 48 | + * // REDIS_BACKOFF_ALGORITHM_EXPONENTIAL |
| 49 | + * // REDIS_BACKOFF_ALGORITHM_FULL_JITTER |
| 50 | + * // REDIS_BACKOFF_ALGORITHM_EQUAL_JITTER |
| 51 | + * // REDIS_BACKOFF_ALGORITHM_DECORRELATED_JITTER |
| 52 | + * // |
| 53 | + * // 'base', and 'cap' are in milliseconds and represent the first |
| 54 | + * // delay redis will use when reconnecting, and the maximum delay |
| 55 | + * // we will reach while retrying. |
| 56 | + * 'backoff' => [ |
| 57 | + * 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, |
| 58 | + * 'base' => 500, |
| 59 | + * 'cap' => 750, |
| 60 | + * ] |
| 61 | + * ]; |
| 62 | + * ?> |
| 63 | + * </code> |
| 64 | + * |
| 65 | + * Note: If you do wish to connect via the constructor, only 'host' is |
| 66 | + * strictly required, which will cause PhpRedis to connect to that |
| 67 | + * host on Redis' default port (6379). |
| 68 | + */ |
11 | 69 | public function __construct(array $options = null); |
12 | 70 |
|
13 | 71 | public function __destruct(); |
|
0 commit comments