Evo C++ Library v0.5.1
|
#include <evo/async/memcached_server.h>
Classes | |
struct | CommandEnum |
Command enum mappings. More... | |
struct | DeferredReply |
Deferred reply helper – deferred event objects should hold or inherit this, and use to send deferred response. More... | |
struct | GetAdvParams |
Additional parameters for advanced GET request variants. More... | |
struct | StoreParams |
STORE command parameters. More... | |
Public Member Functions | |
MemcachedServerHandlerBase () | |
Constructor. More... | |
virtual bool | on_command (bool &handled, SubString &command_str, SubString ¶ms) |
Called on any other command. More... | |
virtual DeleteResult | on_delete (DeferredContext &context, const SubString &key) |
Called on DELETE request to delete key and value. More... | |
virtual void | on_error (AsyncError err) |
Called on error. More... | |
virtual void | on_flush_all (ulong delay_sec) |
Called on FLUSH_ALL request to expire all keys. More... | |
virtual ResponseType | on_get (DeferredContext &context, const SubString &key, GetAdvParams *adv_params) |
Called for each key in GET request. More... | |
virtual ResponseType | on_get_end (DeferredContext &context) |
Called at end of GET request. More... | |
virtual GetStartResult | on_get_start (DeferredContext &context, const SubString &keys, GetAdvParams *adv_params) |
Called at the beginning of a GET request with all requested keys. More... | |
virtual IncrementResult | on_increment (DeferredContext &context, const SubString &key, uint64 count, bool decrement) |
Called on INCR or DECR request to increment or decrement a numeric value. More... | |
virtual void | on_stats (SubString ¶ms) |
Called on STATS request for statistics. More... | |
virtual StoreResult | on_store (DeferredContext &context, StoreParams ¶ms, SubString &value, Command command, uint64 cas_id) |
Called on STORE request to store a value. More... | |
virtual TouchResult | on_touch (DeferredContext &context, const SubString &key, int64 expire) |
Called on TOUCH request to update expiration of existing key without retrieving the value. More... | |
virtual void | on_version (String &version) |
Called on VERSION request for server version. More... | |
void | send_client_error (const SubString &msg) |
Helper to send a client error response. More... | |
void | send_error (const SubString &msg) |
Helper to send a server error response. More... | |
void | send_reply (const SubString &msg) |
Helper to send a reply message. More... | |
void | send_stat (const SubString &name, const SubString &value) |
Helper for sending statistics. More... | |
void | send_value (const SubString &key, const SubString &value, uint32 flags=0, uint64 *cas_id=NULL) |
Helper to send value for get response. More... | |
void | set_id () |
Create and set new ID for current request/response. More... | |
Static Public Member Functions | |
static size_t | get_max_initial_read () |
Public Attributes | |
AsyncBuffers | buffers |
Buffers for async I/O. More... | |
bool | enable_cas |
Derived constructor must set to true to enable "compare and swap" (gets/gats command) More... | |
bool | enable_gat |
Derived constructor must set to true to enable "get and touch" (gat/gats command) More... | |
ulong | id |
Request/reply ID, used by reply manager (set by parent protocol class) More... | |
LoggerPtr | logger |
Logger to use (set by AsyncServer) More... | |
bool | noreply |
Whether no-reply mode is enabled (set by parent protocol class) More... | |
AsyncServerReply | reply |
Server reply manager, used to track deferred events and queue out of order replies. More... | |
Static Public Attributes | |
static const size_t | MAX_INITIAL_READ = 8192 |
Max initial read size. More... | |
typedef DeferredContextT<MemcachedServerHandlerBase> DeferredContext |
Deferred context helper – used by AsyncServer.
typedef ResponseResult<GeneralResultValue> DeleteResult |
DELETE command result returned by on_delete()
GET command result returned by on_get_start()
typedef ResponseResult<UInt64> IncrementResult |
INCR/DECR command result.
typedef evo::async::Memcached Memcached |
Alias for evo::async::Memcached
STORE command result returned by on_store()
typedef ResponseResult<GeneralResultValue> TouchResult |
TOUCH command result returned by on_touch()
enum Command |
Command value.
Enumerator | |
---|---|
cUNKNOWN | Unknown command (always first) |
cADD | Add value if not found. |
cAPPEND | Append to existing value. |
cCAS | Compare and swap |
cDECREMENT | Decrement numeric value for key. |
cDELETE | Delete by key. |
cGAT | Get value and update expiratiom time. |
cGATS | Get value for compare and swap and update expiratiom time. |
cGET | Get value. |
cGETS | Get value for compare and swap. |
cINCREMENT | Increment numeric value for key. |
cPREPEND | Prepend to existing value. |
cQUIT | Quit command to close connection. |
cREPLACE | Replace value if found. |
cSET | Set new value. |
cSTATS | Get server stats. |
cTOUCH | Touch key by updating expiration time. |
cVERSION | Get server version. |
cENUM_END | Enum guard value (always last) |
enum GeneralResultValue |
enum GetStartResultValue |
GET command result from on_get_start().
Enumerator | |
---|---|
gsrCONTINUE | Continue to on_get() events. |
gsrSKIP | Skip on_get() events. |
|
inherited |
Handler response type – used with ResponseResult.
|
inline |
Constructor.
|
inlinestatic |
|
inlinevirtual |
Called on any other command.
handled | Set to true if command handled, otherwise an error response is sent (unknown command) |
command_str | Command string to use |
params | Parameters string received, usually space delimited |
|
inlinevirtual |
Called on DELETE request to delete key and value.
rtHANDLED
or rtCLOSE
context | Context for creating DeferredReply for deferred response |
key | Key to delete |
grOK
if deleted successfullydrNOT_FOUND
if key not foundrtDEFERRED
for deferred response (i.e. must wait for another event)rtHANDLED
if response already sent – use if error was sentrtCLOSE
to stop this request and immediately close connection
|
inlinevirtual |
Called on error.
err | Error code – see AsyncError |
|
inlinevirtual |
Called on FLUSH_ALL request to expire all keys.
delay_sec | Number of seconds to delay the flush, 0 for immediate |
|
inlinevirtual |
Called for each key in GET request.
enable_gat=true
enable_cas=true
enable_gat=true
and enable_cas=true
on_get_start()
returned grCONTINUE
for this requeston_get_start()
or on_get_end()
must return rtDEFERRED
to indiciate this, otherwise results are undefinedcontext | Context for creating DeferredReply for deferred response |
key | Requested key to get |
adv_params | Pointer to advanced params, NULL for normal GET request, non-null if this is an advanced GET variant request (see above) |
rtNORMAL
to continue to next eventrtDEFERRED
to continue, but also mark the response as deferred (i.e. must wait for another event)rtDEFERRED
must have a matching DeferredReply to finish that deferred responsertHANDLED
if response already sent – use if error was sentrtCLOSE
to stop this request and immediately close connection
|
inlinevirtual |
Called at end of GET request.
rtHANDLED
or rtCLOSE
context | Context for creating DeferredReply for deferred response |
rtNORMAL
to complete the GET request – default if method not implementedrtDEFERRED
to mark the response as deferred (i.e. must wait for another event)rtHANDLED
if response already sent – use if error was sentrtCLOSE
to stop this request and close connection
|
inlinevirtual |
Called at the beginning of a GET request with all requested keys.
enable_gat=true
enable_cas=true
enable_gat=true
and enable_cas=true
gsrCONTINUE
if not overriddenrtDEFERRED
context | Context for creating DeferredReply for deferred response |
keys | Requested keys (space separated) |
adv_params | Pointer to advanced params, NULL for normal GET request, non-null if this is an advanced GET variant request (see above)
|
gsrCONTINUE
to continue to on_get()
events for each key – default if not overriddengsrSKIP
to skip on_get()
events – on_get_end()
is still calledrtDEFERRED
to skip on_get()
events and setup for deferred response – on_get_end()
is still calledrtHANDLED
if response already sent – use if error was sent – on_get()
and on_get_end()
will not be called for this responsertCLOSE
to stop this request and immediately close connection
|
inlinevirtual |
Called on INCR or DECR request to increment or decrement a numeric value.
rtHANDLED
or rtCLOSE
context | Context for creating DeferredReply for deferred response |
key | Key to increment or decrement |
count | Count to increment or decrement |
decrement | Whether to decrement instead of increment, false to increment, true to decrement |
rtDEFERRED
for deferred response (i.e. must wait for another event)rtHANDLED
if response already sent – use if error was sentrtCLOSE
to stop this request and immediately close connection
|
inlinevirtual |
Called on STATS request for statistics.
params | Parameter string received |
|
inlinevirtual |
Called on STORE request to store a value.
enable_cas=true
rtHANDLED
or rtCLOSE
command
is not supported do this: context | Context for creating DeferredReply for deferred response |
params | Storage parameters to use |
value | Value to store |
command | Exact store command used, one of: cSET, cAPPEND, cPREPEND, cADD, cREPLACE, cCAS
|
cas_id | Compare And Swap ID from previous "gets" or "gats" command – positive for cCAS command, otherwise always 0 |
Memcached::srSTORED
if value successfully stored, or if 'noreply' flag is setMemcached::srNOT_STORED
if not stored due to unmet condition (cADD, cREPLACE, cAPPEND, cPREPEND)Memcached::srEXISTS
if Compare And Swap failed due to value being modified since last retrieved with cas_id
(cCAS only)Memcached::srNOT_FOUND
if Compare And Swap failed due to value not existing (cCAS only)rtDEFERRED
for deferred response (i.e. must wait for another event)rtHANDLED
if response already sent – use if error was sentrtCLOSE
to stop this request and immediately close connection
|
inlinevirtual |
Called on TOUCH request to update expiration of existing key without retrieving the value.
rtHANDLED
or rtCLOSE
context | Context for creating DeferredReply for deferred response |
key | Key to delete |
expire | New expiration time in seconds from now, 0 for no expiration, negative to expire now, or a value greater than 2592000 (30 days) means a Unix timestamp to expire on |
grOK
if successfuldrNOT_FOUND
if key not foundrtDEFERRED
for deferred response (i.e. must wait for another event)rtHANDLED
if response already sent – use if error was sentrtCLOSE
to stop this request and immediately close connection
|
inlinevirtual |
Called on VERSION request for server version.
version | Set to version string to return (no newline chars) [out] |
|
inline |
Helper to send a client error response.
msg | Error message to send |
|
inline |
Helper to send a server error response.
msg | Error message to send |
|
inline |
Helper to send a reply message.
msg | Reply message to send |
Helper for sending statistics.
name | Stats name |
value | Stats value |
|
inline |
Helper to send value for get response.
key | Key for value |
value | Value to send |
flags | User defined flags stored with value |
cas_id | Compare-And-Swap ID to send, NULL for none – this must only be non-null for CAS GET request variants, see GetAdvParams |
|
inlineinherited |
Create and set new ID for current request/response.
|
inherited |
Buffers for async I/O.
bool enable_cas |
Derived constructor must set to true to enable "compare and swap" (gets/gats command)
bool enable_gat |
Derived constructor must set to true to enable "get and touch" (gat/gats command)
|
inherited |
Request/reply ID, used by reply manager (set by parent protocol class)
LoggerPtr logger |
Logger to use (set by AsyncServer)
|
staticinherited |
Max initial read size.
bool noreply |
Whether no-reply mode is enabled (set by parent protocol class)
|
inherited |
Server reply manager, used to track deferred events and queue out of order replies.