Download the PHP package seregazhuk/react-memcached without Composer
On this page you can find all versions of the php package seregazhuk/react-memcached. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download seregazhuk/react-memcached
More information about seregazhuk/react-memcached
Files in seregazhuk/react-memcached
Package react-memcached
Short Description Async Memcached client implementation, built on top of ReactPHP
License MIT
Homepage https://github.com/seregazhuk/php-react-memcached
Informations about the package react-memcached
Asynchronous Memcached PHP Client for ReactPHP ecosystem.
Table of Contents
- Installation
- Quick Start
- Server Address
- Client
- Retrieval Commands
- Get
- Storage Commands
- Set
- Add
- Replace
- Delete Command
- Increment/Decrement Commands
- Increment
- Decrement
- Touch Command
- Statistics Command
- Misc Commands
- Flush all
- Version
- Verbosity
- Connection Closing
- [End](#end())
- [Close](#close())
- Events Handling
- Errors Handling
Installation
Dependencies
Library requires PHP 5.6.0 or above.
The recommended way to install this library is via Composer. New to Composer?
See also the CHANGELOG for details about version upgrades.
Quick Start
See other examples.
Server address
When creating a client via the factory you can specify server address as a second argument:
If the address is not specified the client uses default localhost:11211
.
Asynchronous Execution
For each Memcached command a client has a method. All commands are executed asynchronously. The client stored pending requests and once it receives the response from the server, it starts resolving these requests. That means that each command returns a promise. When the server executed a command and returns a response, the promise will be resolved with this response. If there was an error, the promise will be rejected.
Retrieval Commands
Get
Get value from key:
Storage Commands
For $flags
you can use PHP MEMCACHE_COMPRESSED
constant to specify on-the-fly compression.
If the value was not stored indicate because condition for add
or replace
commands wasn’t met, or the item was in
a delete queue, the promise will be rejected with FailedCommandException
.
Set
Store key/value pair in Memcached:
Add
Store key/value pair in Memcached, but only if the server doesn’t already hold data for this key:
Replace
Store key/value pair in Memcached, but only if the server already hold data for this key:
Delete Command
Delete value by key from Memcached.
If the key doesn't exist or has been deleted the promise rejects with FailedCommandException
:
Increment/Decrement Commands
Increment
Increment value associated with key in Memcached, item must exist, increment command will not create it.
The limit of increment is the 64 bit mark. If key is not found, the promise will be rejected with FailedCommandException
:
Decrement
Decrement value associated with key in Memcached, item must exist, decrement command will not create it
If you try to decrement a value bellow 0, value will stay at 0. If key is not found, the promise
will be rejected with FailedCommandException
:
If value not found, the promise will be rejected with FailedCommandException
.
Touch Command
The touch command is used to update the expiration time of an existing item without fetching it. If the key doesn't
exist or has been deleted the promise rejects with FailedCommandException
:
Statistics Command
This command can return an array of various stats:
Misc Commands
Flush all
Flush the server key/value pairs (invalidating them) after an optional [
Version
Return the Memcached server version:
Verbosity
Change the verbosity output of Memcached server:
Connection Closing
End()
To close the connection call end()
method on the client. The client waits till all pending requests are resolved and
then closes the connection. All new requests to the client will be rejected with ConnectionClosedException
exception.
Close()
If you want to force the closing and don't want to wait for pending requests to be resolved, call close()
method. It
immediately closes the connection and rejects all pending requests with ConnectionClosedException
exception.
Events Handling
You can register event handlers for some client's events.
close
When the connection to Memcached server is closed, the close
event is emitted. You can listen to this event to catch
connection failures:
error
When an error occurs in the connection, the client emits error
event and passes an exception
with the problem description:
For example you can handle broken connections like this:
Errors Handling
All exceptions that are thrown by the client or are used to reject the promises extend from the
base seregazhuk\React\Memcached\Exception\Exception
class.
For example, if you call an unknown Memcached command the promise will be rejected with WrongCommandException
:
When the connection is broken all pending promises will be rejected with ConnectionClosedException
exception.
All versions of react-memcached with dependencies
react/socket Version ^1.0
react/promise Version ^2.7
react/event-loop Version ^1.0
evenement/evenement Version 3