PromPHP / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
423 stars 93 forks source link

bugfix: addItemToKey calls apcu_store() even when the array key exists #75

Closed thedeacon closed 2 years ago

thedeacon commented 2 years ago

This is more of a performance increase, since the buggy behavior just causes addItemToKey to write to APC more often than necessary. However, the write is idempotent: repeatedly setting $arr[$xxx] = 1 and saving the array to APC doesn't affect the correctness of the result, nor does fixing it change the storage format. It just prevents unnecessary writes to APC when the array already contains $arr[$xxx] for some value of $xxx.

Signed-off-by: Paul Kreiner github-paul@thedeacon.org

LKaemmerling commented 2 years ago

Good catch! Thank you