Skip to content

Commit 44d8598

Browse files
Changed config name from responseSizeDecoderSwitch to jsonStreamDecoderThreshold (#32)
1 parent 5ddafca commit 44d8598

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

docs/arangodb-client.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Upon creation, you can alter the default configuration of the client. The follow
1313
* username = null
1414
* password = null
1515
* database = '_system'
16-
* responseSizeDecoderSwitch = 1 * 1024 * 1024
16+
* jsonStreamDecoderThreshold = 1 * 1024 * 1024
1717

1818
```
1919
$config = [
@@ -31,7 +31,7 @@ JSON response decoding is normally done by the default json_decode method. This
3131
is optimized for speed and can take a large amount of memory; up to ~ 20x of the JSON size.
3232

3333
Therefor we use halaxa/json-machine to stream decode for responses larger than 1MB.
34-
You can alter this cutoff by setting the `responseSizeDecoderSwitch` to a different size in **Bytes**.
34+
You can alter this cutoff by setting the `jsonStreamDecoderThreshold` to a different size in **Bytes**.
3535

3636
This removed any memory issues at the cost of speed.
3737

src/HandlesJson.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function jsonEncode(mixed $data): string
3838
protected function decodeJsonResponse(ResponseInterface $response): stdClass
3939
{
4040
$contentLength = $response->getHeaderLine('Content-Length');
41-
$sizeSwitch = $this->getConfig('responseSizeDecoderSwitch');
41+
$sizeSwitch = $this->getConfig('jsonStreamDecoderThreshold');
4242
if ($contentLength < $sizeSwitch) {
4343
return json_decode($response->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR);
4444
}

src/Http/HttpClientConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class HttpClientConfig extends DataTransferObject
4040
/**
4141
* Small responses are decoded with json_decode. This is fast but memory intensive.
4242
* Large responses are decoded with Halaxa/json-machine stream decoder.
43-
* $responseSizeDecoderSwitch is the response length cutoff in bytes which determines which decoder is used.
43+
* $jsonStreamDecoderThreshold is the response length cutoff in bytes which determines which decoder is used.
4444
*
4545
* @var int
4646
*/
47-
public int $responseSizeDecoderSwitch = 1 * 1024 * 1024; // Default 1 MB
47+
public int $jsonStreamDecoderThreshold = 1 * 1024 * 1024; // Default 1 MB
4848

4949
/**
5050
* @return array<array<mixed>|string|numeric|bool|null>

tests/ArangoClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testGetConfig()
3131
'username' => 'root',
3232
'password' => null,
3333
'database' => $this->testDatabaseName,
34-
'responseSizeDecoderSwitch' => 1048576,
34+
'jsonStreamDecoderThreshold' => 1048576,
3535
];
3636

3737
$config = $this->arangoClient->getConfig();

0 commit comments

Comments
 (0)