Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the native implementation for Memcached::decrement #4307

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions hphp/runtime/ext/memcached/ext_memcached.php
Expand Up @@ -204,12 +204,11 @@ public function casByKey(float $cas_token,
*
* @return int - Returns item's new value on success.
*/
<<__Native>>
public function decrement(string $key,
int $offset = 1,
int $initial_value = 0,
int $expiry = 0): mixed {
return $this->decrementByKey('', $key, $offset, $initial_value, $expiry);
}
int $expiry = 0): mixed;

/**
* Decrement numeric item's value, stored on a specific server
Expand Down
11 changes: 11 additions & 0 deletions hphp/test/slow/ext_memcached/dec_key.php
@@ -0,0 +1,11 @@
<?php
$mc = new Memcached;
$mc->addServer('127.0.0.1', 11211);
$mc->addServer('127.0.0.1', 11212);
for ($i = 1; $i <= 10; $i++) {
$key = "dec_test_{$i}";
$mc->set($key, 10);
var_dump($mc->get($key) === 10);
$mc->decrement($key, 1);
var_dump($mc->get($key) === 9);
}
20 changes: 20 additions & 0 deletions hphp/test/slow/ext_memcached/dec_key.php.expect
@@ -0,0 +1,20 @@
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
9 changes: 9 additions & 0 deletions hphp/test/slow/ext_memcached/dec_key.php.skipif
@@ -0,0 +1,9 @@
<?php

$memc = new Memcached();
$memc->addServer('localhost', '11211');
$memc->addServer('localhost', '11212');
$version = $memc->getVersion();
if (!is_array($version) || count($version) !== 2) {
echo "SKIP Need two Memcached servers running (port 11211 and 11212)";
}