@@ -32,15 +32,15 @@ class Connection
32
32
'group ' => 'symfony ' ,
33
33
'consumer ' => 'consumer ' ,
34
34
'auto_setup ' => true ,
35
- 'xadd_maxlength ' => 0 , // 0 disables trimming, any other value defines an approximate maximum length
35
+ 'stream_max_entries ' => 0 , // any value higher than 0 defines an approximate maximum number of stream entries
36
36
];
37
37
38
38
private $ connection ;
39
39
private $ stream ;
40
40
private $ group ;
41
41
private $ consumer ;
42
42
private $ autoSetup ;
43
- private $ xaddMaxLength ;
43
+ private $ maxEntries ;
44
44
private $ couldHavePendingMessages = true ;
45
45
46
46
public function __construct (array $ configuration , array $ connectionCredentials = [], array $ redisOptions = [], \Redis $ redis = null )
@@ -52,7 +52,7 @@ public function __construct(array $configuration, array $connectionCredentials =
52
52
$ this ->group = $ configuration ['group ' ] ?? self ::DEFAULT_OPTIONS ['group ' ];
53
53
$ this ->consumer = $ configuration ['consumer ' ] ?? self ::DEFAULT_OPTIONS ['consumer ' ];
54
54
$ this ->autoSetup = $ configuration ['auto_setup ' ] ?? self ::DEFAULT_OPTIONS ['auto_setup ' ];
55
- $ this ->xaddMaxLength = $ configuration ['xadd_maxlength ' ] ?? self ::DEFAULT_OPTIONS ['xadd_maxlength ' ];
55
+ $ this ->maxEntries = $ configuration ['stream_max_entries ' ] ?? self ::DEFAULT_OPTIONS ['stream_max_entries ' ];
56
56
}
57
57
58
58
public static function fromDsn (string $ dsn , array $ redisOptions = [], \Redis $ redis = null ): self
@@ -82,18 +82,18 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
82
82
unset($ redisOptions ['auto_setup ' ]);
83
83
}
84
84
85
- $ xaddMaxLength = null ;
86
- if (\array_key_exists ('xadd_maxlength ' , $ redisOptions )) {
87
- $ xaddMaxLength = filter_var ($ redisOptions ['xadd_maxlength ' ], FILTER_VALIDATE_INT );
88
- unset($ redisOptions ['xadd_maxlength ' ]);
85
+ $ maxEntries = null ;
86
+ if (\array_key_exists ('stream_max_entries ' , $ redisOptions )) {
87
+ $ maxEntries = filter_var ($ redisOptions ['stream_max_entries ' ], FILTER_VALIDATE_INT );
88
+ unset($ redisOptions ['stream_max_entries ' ]);
89
89
}
90
90
91
91
return new self ([
92
92
'stream ' => $ stream ,
93
93
'group ' => $ group ,
94
94
'consumer ' => $ consumer ,
95
95
'auto_setup ' => $ autoSetup ,
96
- 'xadd_maxlength ' => $ xaddMaxLength ,
96
+ 'stream_max_entries ' => $ maxEntries ,
97
97
], $ connectionCredentials , $ redisOptions , $ redis );
98
98
}
99
99
@@ -181,10 +181,10 @@ public function add(string $body, array $headers): void
181
181
182
182
$ e = null ;
183
183
try {
184
- if ($ this ->xaddMaxLength ) {
184
+ if ($ this ->maxEntries ) {
185
185
$ added = $ this ->connection ->xadd ($ this ->stream , '* ' , ['message ' => json_encode (
186
186
['body ' => $ body , 'headers ' => $ headers ]
187
- )], $ this ->xaddMaxLength , true );
187
+ )], $ this ->maxEntries , true );
188
188
} else {
189
189
$ added = $ this ->connection ->xadd ($ this ->stream , '* ' , ['message ' => json_encode (
190
190
['body ' => $ body , 'headers ' => $ headers ]
0 commit comments