| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
// Fix for "Memcached::increment(): Initial value is only supported with binary protocol"
$m = new Memcached();
$m->addServer('localhost', 11211);
// Option 1: Or, add the key first to avoid needing initial value support
$m->add($key, $initial_value, $expiry);
$m->increment($key, $offset);
// Option 2: Use binary protocol to support initial value in increment()
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$m->increment($key, $offset, $initial_value, $expiry);
Tested on PHP 8.4.8
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 114.122.110.140)
----
Manual Page -- https://php.net/manual/en/memcached.increment.php
Edit -- https://main.php.net/note/edit/130385
Del: integrated -- https://main.php.net/note/delete/130385/integrated
Del: useless -- https://main.php.net/note/delete/130385/useless
Del: bad code -- https://main.php.net/note/delete/130385/bad+code
Del: spam -- https://main.php.net/note/delete/130385/spam
Del: non-english -- https://main.php.net/note/delete/130385/non-english
Del: in docs -- https://main.php.net/note/delete/130385/in+docs
Del: other reasons-- https://main.php.net/note/delete/130385
Reject -- https://main.php.net/note/reject/130385
Search -- https://main.php.net/manage/user-notes.php