Skip to content

Commit

Permalink
chore: cleanup acpu inc and dec
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jul 10, 2024
1 parent ef64f41 commit 32aee4c
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions lib/private/Memcache/APCu.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,8 @@ public function add($key, $value, $ttl = 0) {
* @return int | bool
*/
public function inc($key, $step = 1) {
$this->add($key, 0);
/**
* TODO - hack around a PHP 7 specific issue in APCu
*
* on PHP 7 the apcu_inc method on a non-existing object will increment
* "0" and result in "1" as value - therefore we check for existence
* first
*
* on PHP 5.6 this is not the case
*
* see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
* for details
*/
return apcu_exists($this->getPrefix() . $key)
? apcu_inc($this->getPrefix() . $key, $step)
: false;
$success = null;
return apcu_inc($this->getPrefix() . $key, $step, $success, self::DEFAULT_TTL);
}

/**
Expand All @@ -99,18 +85,6 @@ public function inc($key, $step = 1) {
* @return int | bool
*/
public function dec($key, $step = 1) {
/**
* TODO - hack around a PHP 7 specific issue in APCu
*
* on PHP 7 the apcu_dec method on a non-existing object will decrement
* "0" and result in "-1" as value - therefore we check for existence
* first
*
* on PHP 5.6 this is not the case
*
* see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
* for details
*/
return apcu_exists($this->getPrefix() . $key)
? apcu_dec($this->getPrefix() . $key, $step)
: false;
Expand Down

0 comments on commit 32aee4c

Please sign in to comment.