Skip to content

Commit 7900bb4

Browse files
authored
revert incr/decr changes
1 parent abe8585 commit 7900bb4

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
- Changed `wp_cache_*()` function signatures to match core
5+
- Revert (in|de)crement changes from v2.6.0
56

67
## 2.6.5
78

includes/object-cache.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,14 +2410,9 @@ public function increment( $key, $offset = 1, $group = 'default' ) {
24102410
}
24112411

24122412
try {
2413-
$value = (int) $this->parse_redis_response( $this->maybe_unserialize( $this->redis->get( $derived_key ) ) );
2414-
$value += $offset;
2415-
$result = $this->parse_redis_response( $this->redis->set( $derived_key, $this->maybe_serialize( $value ) ) );
2413+
$result = $this->parse_redis_response( $this->redis->incrBy( $derived_key, $offset ) );
24162414

2417-
if ( $result ) {
2418-
$this->add_to_internal_cache( $derived_key, $value );
2419-
$result = $value;
2420-
}
2415+
$this->add_to_internal_cache( $derived_key, (int) $this->redis->get( $derived_key ) );
24212416
} catch ( Exception $exception ) {
24222417
$this->handle_exception( $exception );
24232418

@@ -2472,14 +2467,9 @@ public function decrement( $key, $offset = 1, $group = 'default' ) {
24722467
}
24732468

24742469
try {
2475-
$value = (int) $this->parse_redis_response( $this->maybe_unserialize( $this->redis->get( $derived_key ) ) );
2476-
$value -= $offset;
2477-
$result = $this->parse_redis_response( $this->redis->set( $derived_key, $this->maybe_serialize( $value ) ) );
2470+
$result = $this->parse_redis_response( $this->redis->decrBy( $derived_key, $offset ) );
24782471

2479-
if ( $result ) {
2480-
$this->add_to_internal_cache( $derived_key, $value );
2481-
$result = $value;
2482-
}
2472+
$this->add_to_internal_cache( $derived_key, (int) $this->redis->get( $derived_key ) );
24832473
} catch ( Exception $exception ) {
24842474
$this->handle_exception( $exception );
24852475

0 commit comments

Comments
 (0)