Skip to content

Commit

Permalink
DDEV-1965 fix updateGauge and updateCounter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Davydenko committed Nov 18, 2024
1 parent fe662f4 commit aabd94c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Storage/OctaneCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,16 @@ public function updateGauge(array $data): void
'valueKeys' => '',
];
}
if (!$this->gaugeValues->get($valueKey)) {
$value = 0;
}
if (!$this->gaugeValues->get($valueKey)) {
$value = $this->gaugeValues->get($valueKey) ?? 0;

$value = $this->сounterValues->get($valueKey);
if (!$value) {
$value = ['value' => 0];
$metaKeyValue['valueKeys'] = $this->implodeKeysString($metaKeyValue['valueKeys'], $valueKey);
}
if ($data['command'] === Adapter::COMMAND_SET) {
$this->gaugeValues->set($valueKey, ['value' => $data['value']]);
} else {
$this->gaugeValues->set($valueKey, ['value' => $value + $data['value']]);
$this->gaugeValues->set($valueKey, ['value' => $value['value'] + $data['value']]);
}

$this->gauges->set($metaKey, $metaKeyValue);
Expand All @@ -191,14 +190,15 @@ public function updateCounter(array $data): void
'valueKeys' => '',
];
}
$value = $this->сounterValues->get($valueKey) ?? 0;
$value = $this->сounterValues->get($valueKey);
if (!$value) {
$value = ['value' => 0];
$metaKeyValue['valueKeys'] = $this->implodeKeysString($metaKeyValue['valueKeys'], $valueKey);
}
if ($data['command'] === Adapter::COMMAND_SET) {
$this->сounterValues->set($valueKey, ['value' => 0]);
} else {
$this->сounterValues->set($valueKey, ['value' => $value + $data['value']]);
$this->сounterValues->set($valueKey, ['value' => $value['value'] + $data['value']]);
}

$this->сounters->set($metaKey, $metaKeyValue);
Expand Down

0 comments on commit aabd94c

Please sign in to comment.