Skip to content

Commit bf63f87

Browse files
committed
fix(redis): set persistent_id so phpredis also keeps one socket per connection
Laravel's PhpRedisConnector reads 'persistent' only as a flag and takes the socket id from 'persistent_id'. predis ignores the key. Signed-off-by: smarcet <smarcet@gmail.com>
1 parent 18b1888 commit bf63f87

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎config/database.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
* REDIS_PERSISTENT=true keeps one TLS socket per connection in each php-fpm worker,
107107
* so requests skip the TLS handshake. Every connection needs its own persistent id:
108108
* they share host:port, and a shared socket would let one connection's SELECT
109-
* switch the database of another within the same request.
109+
* switch the database of another within the same request. predis takes the id from
110+
* 'persistent', phpredis from 'persistent_id'; both are set so either client is safe.
110111
*/
111112

112113
'default' => [
@@ -117,6 +118,7 @@
117118
'timeout' => env('REDIS_TIMEOUT', 30.0),
118119
'scheme' => env('REDIS_SCHEME', 'tcp'),
119120
'persistent' => env('REDIS_PERSISTENT', false) ? 'openstackid_default' : false,
121+
'persistent_id' => 'openstackid_default',
120122
],
121123

122124
'cache' => [
@@ -127,6 +129,7 @@
127129
'timeout' => env('REDIS_TIMEOUT', 30.0),
128130
'scheme' => env('REDIS_SCHEME', 'tcp'),
129131
'persistent' => env('REDIS_PERSISTENT', false) ? 'openstackid_cache' : false,
132+
'persistent_id' => 'openstackid_cache',
130133
],
131134

132135
'session' => [
@@ -137,6 +140,7 @@
137140
'timeout' => env('REDIS_TIMEOUT', 30.0),
138141
'scheme' => env('REDIS_SCHEME', 'tcp'),
139142
'persistent' => env('REDIS_PERSISTENT', false) ? 'openstackid_session' : false,
143+
'persistent_id' => 'openstackid_session',
140144
],
141145

142146
'worker' => [
@@ -147,6 +151,7 @@
147151
'timeout' => env('REDIS_TIMEOUT', 30.0),
148152
'scheme' => env('REDIS_SCHEME', 'tcp'),
149153
'persistent' => env('REDIS_PERSISTENT', false) ? 'openstackid_worker' : false,
154+
'persistent_id' => 'openstackid_worker',
150155
],
151156
'doctrine_cache' => [
152157
'host' => env('REDIS_HOST'),
@@ -156,6 +161,7 @@
156161
'timeout' => env('REDIS_TIMEOUT', 30.0),
157162
'scheme' => env('REDIS_SCHEME', 'tcp'),
158163
'persistent' => env('REDIS_PERSISTENT', false) ? 'openstackid_doctrine_cache' : false,
164+
'persistent_id' => 'openstackid_doctrine_cache',
159165
],
160166
],
161167
'allow_disabled_pk' => env('ALLOW_DISABLED_PK', false),

0 commit comments

Comments
 (0)