Cutelyst
2.13.0
|
Cutelyst Memcached plugin. More...
#include <memcached.h>
Public Types | |
enum | MemcachedReturnType { Success, Failure, HostLookupFailure, ConnectionFailure, WriteFailure, ReadFailure, UnknownReadFailure, ProtocolError, ClientError, ServerError, Error, DataExists, DataDoesNotExist, NotStored, Stored, NotFound, MemoryAllocationFailure, PartialRead, SomeErrors, NoServers, End, Deleted, Stat, Errno, NotSupported, FetchNotFinished, Timeout, Buffered, BadKeyProvided, InvalidHostProtocol, ServerMarkedDead, UnknownStatKey, E2Big, InvalidArguments, KeyTooBig, AuthProblem, AuthFailure, AuthContinue, ParseError, ParseUserError, Deprecated, InProgress, ServerTemporaryDisabled, ServerMemoryAllocationFailure, MaximumReturn, PluginNotRegisterd } |
Public Member Functions | |
Memcached (Application *parent) | |
virtual | ~Memcached () override |
void | setDefaultConfig (const QVariantMap &defaultConfig) |
![]() | |
Plugin (Application *parent) | |
Static Public Member Functions | |
static bool | add (const QString &key, const QByteArray &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | add (const QString &key, const T &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | addByKey (const QString &groupKey, const QString &key, const QByteArray &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | addByKey (const QString &groupKey, const QString &key, const T &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | cas (const QString &key, const QByteArray &value, time_t expiration, uint64_t cas, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | cas (const QString &key, const T &value, time_t expiration, uint64_t cas, MemcachedReturnType *returnType=nullptr) |
static bool | casByKey (const QString &groupKey, const QString &key, const QByteArray &value, time_t expiration, uint64_t cas, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | casByKey (const QString &groupKey, const QString &key, const T &value, time_t expiration, uint64_t cas, MemcachedReturnType *returnType=nullptr) |
static bool | decrement (const QString &key, uint32_t offset, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | decrementByKey (const QString &groupKey, const QString &key, uint64_t offset, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | decrementWithInitial (const QString &key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | decrementWithInitialByKey (const QString &groupKey, const QString &key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static QString | errorString (Context *c, MemcachedReturnType rt) |
static bool | exist (const QString &key, MemcachedReturnType *returnType=nullptr) |
static bool | existByKey (const QString &groupKey, const QString &key, MemcachedReturnType *returnType=nullptr) |
static bool | flush (time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | flushBuffers (MemcachedReturnType *returnType=nullptr) |
static QByteArray | get (const QString &key, uint64_t *cas=nullptr, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static T | get (const QString &key, uint64_t *cas=nullptr, MemcachedReturnType *returnType=nullptr) |
static QByteArray | getByKey (const QString &groupKey, const QString &key, uint64_t *cas=nullptr, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static T | getByKey (const QString &groupKey, const QString &key, uint64_t *cas=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | increment (const QString &key, uint32_t offset, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | incrementByKey (const QString &groupKey, const QString &key, uint64_t offset, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | incrementWithInitial (const QString &key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | incrementWithInitialByKey (const QString &groupKey, const QString &key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, MemcachedReturnType *returnType=nullptr) |
static QVersionNumber | libMemcachedVersion () |
Returns the version of the currently used libmemcached. | |
static QHash< QString, QByteArray > | mget (const QStringList &keys, QHash< QString, uint64_t > *casValues=nullptr, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static QHash< QString, T > | mget (const QStringList &keys, QHash< QString, uint64_t > *casValues=nullptr, MemcachedReturnType *returnType=nullptr) |
static QHash< QString, QByteArray > | mgetByKey (const QString &groupKey, const QStringList &keys, QHash< QString, uint64_t > *casValues=nullptr, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static QHash< QString, T > | mgetByKey (const QString &groupKey, const QStringList &keys, QHash< QString, uint64_t > *casValues=nullptr, MemcachedReturnType *returnType=nullptr) |
static bool | remove (const QString &key, MemcachedReturnType *returnType=nullptr) |
static bool | removeByKey (const QString &groupKey, const QString &key, MemcachedReturnType *returnType=nullptr) |
static bool | replace (const QString &key, const QByteArray &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | replace (const QString &key, const T &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | replaceByKey (const QString &groupKey, const QString &key, const QByteArray &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | replaceByKey (const QString &groupKey, const QString &key, const T &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | set (const QString &key, const QByteArray &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | set (const QString &key, const T &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | setByKey (const QString &groupKey, const QString &key, const QByteArray &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
template<typename T > | |
static bool | setByKey (const QString &groupKey, const QString &key, const T &value, time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | touch (const QString &key, time_t expiration, MemcachedReturnType *returnType=nullptr) |
static bool | touchByKey (const QString &groupKey, const QString &key, time_t expiration, MemcachedReturnType *returnType=nullptr) |
Static Public Attributes | |
static const time_t | expirationNotAdd |
Protected Member Functions | |
virtual bool | setup (Application *app) override |
The Memcached plugin for Cutelyst can be used to store, retrieve, delete and modify data on a memcached general-purpose distributed memory caching system. It uses libmemcached to connect to a pool of memcached servers and to perform the caching operations. In order to build this plugin, the libmemcached development and header files have to be present at build time.
Basically all values are stored as QByteArray. So, to store simple types, simply convert them into a QByteArray and vice versa on retrieval. For more complex or custom types you can use QDataStream to serialize them into a QByteArray. For most methods in this plugin there are template functions for convenience that perform this serialization. The requirement to use them is that the types to store and get provide stream operators for QDataStream.
The Memcached plugin can be configured in the cutelyst configuration file in the Cutelyst_Memcached_Plugin
section. It uses the same configuration strings as libmemcached but in lowercase and without the dashes in front and for consistence - replaced by _ . So –BINARY-PROTOCOL
will be binary_protocol
. To add servers and/or sockets use the servers configuration key. Servers can be added with name, port and weight, separated by , - multiple servers are separated by a
; . To add sockets, use a full path as name. If no configuration has been set or if the servers configuration key is empty, a default server at localhost on port 11211 will be used.
Additional to the configuration options of libmemcached there are some plugin specific options:
To set default values directly in your application, use setDefaultConfig(). Configuration values that can not be found in the Cutelyst configuration file will be looked up for default values in that QVariantMap.
Expiration times are set in seconds. If the value is bigger than 30 days, it is interpreted as a unix timestamp.
Messages from this plugin are logged to the logging category cutelyst.plugin.memcached. All methods provide the possibility to specify a pointer to a MemcachedReturnType variable that can provide further information about occured errors if methods return false
or empty results.
To build this plugin you need the development and header files for libmemcached and run cmake with -DPLUGIN_MEMCACHED:BOOL=ON
.
Enabling the build of the Memcached plugin will also enable the unit tests for this plugin. To perform the unit tests, there has to be at least one memcached server running. By default, the test uses a memcached server on localhost and default port 11211. To improve testing and/or to use other and/or multiple servers, you can set the CUTELYST_MEMCACHED_TEST_SERVERS
environment variable in your build environment to define different servers. The syntax is the same as for adding servers in the configuration file. If you have for examble two servers, one on default location and another one on a unix socket, use the following for in bash:
Definition at line 142 of file memcached.h.
Return types for memcached operations.
Enumerator | |
---|---|
Success | The request was successfully executed. |
Failure | A unknown failure has occurred in the server. |
HostLookupFailure | A DNS failure has occurred. |
ConnectionFailure | A unknown error has occured while trying to connect to a server. |
WriteFailure | An error has occured while trying to write to a server. |
ReadFailure | A read failure has occurred. |
UnknownReadFailure | An unknown read failure only occurs when either there is a bug in the server, or in rare cases where an ethernet nic is reporting dubious information. |
ProtocolError | An unknown error has occurred in the protocol. |
ClientError | An unknown client error has occured internally. |
ServerError | An unknown error has occurred in the server. |
Error | A general error occured. |
DataExists | The data requested with the key given was found. |
DataDoesNotExist | The data requested with the key given was not found. |
NotStored | The request to store an object failed. |
Stored | The requested object has been successfully stored on the server. |
NotFound | The object requested was not found. |
MemoryAllocationFailure | An error has occurred while trying to allocate memory. |
PartialRead | The read was only partially successful. |
SomeErrors | A multi request has been made, and some underterminate number of errors have occurred. |
NoServers | No servers have been added to the memcached_st object. |
End | The server has completed returning all of the objects requested. |
Deleted | The object requested by the key has been deleted. |
Stat | A “stat” command has been returned in the protocol. |
Errno | An error has occurred in the driver which has set errno. |
NotSupported | The given method is not supported in the server. |
FetchNotFinished | A request has been made, but the server has not finished the fetch of the last request. |
Timeout | Operation has timed out. |
Buffered | The request has been buffered. |
BadKeyProvided | The key provided is not a valid key. |
InvalidHostProtocol | The server you are connecting too has an invalid protocol. Most likely you are connecting to an older server that does not speak the binary protocol. |
ServerMarkedDead | The requested server has been marked dead. |
UnknownStatKey | The server you are communicating with has a stat key which has not be defined in the protocol. |
E2Big | Item is too large for the server to store. |
InvalidArguments | The arguments supplied to the given function were not valid. |
KeyTooBig | The key that has been provided is too large for the given server. |
AuthProblem | An unknown issue has occured during authentication. |
AuthFailure | The credentials provided are not valid for this server. |
AuthContinue | Authentication has been paused. |
ParseError | An error has occurred while trying to parse the configuration string. You should use memparse to determine what the error was. |
ParseUserError | An error has occurred in parsing the configuration string. |
Deprecated | The method that was requested has been deprecated. |
PluginNotRegisterd | The Cutelyst Memcached plugin has not been registered to the application. |
Definition at line 160 of file memcached.h.
Memcached::Memcached | ( | Application * | parent | ) |
Constructs a new Memcached object with the given parent.
Definition at line 36 of file memcached.cpp.
|
overridevirtual |
Deconstructs the Memcached object.
Definition at line 42 of file memcached.cpp.
|
static |
Adds the value to the memcached server using key. If the object is found on the server an error occurs and this method returns false
, otherwise the value is stored.
As this method returns false
if the key has already been set on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of already existing key will not be logged.
[in] | key | key of object whose value to add |
[in] | value | value of object to add to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 327 of file memcached.cpp.
References PluginNotRegisterd.
Referenced by add().
|
static |
Adds the value of type T to the memcached server using key. If the object is found on the server an error occurs and this method returns false
, otherwise the value is stored.
Type T has to be serializable into a QByteArray using QDataStream.
As this method returns false
if the key has already been set on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of already existing key will not be logged.
[in] | key | key of object whose value to add |
[in] | value | value of type T of object to add to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 987 of file memcached.h.
References add().
|
static |
Adds the value to the memcached server using key. If the object is found on the server an error occurs and this method returns false
, otherwise the value is stored. This method is functionally equivalent to Memcached::add(), except that the free-form groupKey can be used to map the key to a specific server. This allows related items to be grouped together on a single server for efficiency.
As this method returns false
if the key has already been set on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of already existing key will not be logged.
[in] | groupKey | key that specifies the server to write to |
[in] | key | key of object whose value to add |
[in] | value | value of object to add to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 366 of file memcached.cpp.
References PluginNotRegisterd.
Referenced by addByKey().
|
static |
Adds the value of type T to the memcached server using key. If the object is found on the server an error occurs and this method returns false
, otherwise the value is stored. This method is functionally equivalent to Memcached::add(), except that the free-form groupKey can be used to map the key to a specific server. This allows related items to be grouped together on a single server for efficiency.
Type T has to be serializable into a QByteArray using QDataStream.
As this method returns false
if the key has already been set on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of already existing key will not be logged.
[in] | groupKey | key that specifies the server to write to |
[in] | key | key of object whose value to add |
[in] | value | value of object to add to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 996 of file memcached.h.
References addByKey().
|
static |
Overwrites data for key in the server as long as the cas value is still the same in the server. You can get the cas value by using the cas return value of Memcached::get()
[in] | key | key of object whose value to compare and set |
[in] | value | value of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[in] | cas | the cas value to compare |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 964 of file memcached.cpp.
References PluginNotRegisterd.
Referenced by cas(), casByKey(), get(), and getByKey().
|
static |
Overwrites data for key in the server as long as the cas value is still the same in the server. You can get the cas value by using the cas return value of Memcached::get()
Type T has to be serializable into a QByteArray using QDataStream.
[in] | key | key of object whose value to compare and set |
[in] | value | value of type T of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[in] | cas | the cas value to compare |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1047 of file memcached.h.
References cas().
|
static |
Overwrites data for key in groupKey in the server as long as the cas value is still the same in the server. You can get the cas value by using the cas return value of Memcached::getByKey().
This method behaves in a similar nature as Memcached::cas(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupkey | key that specifies the server to write to |
[in] | key | key of object whose value to compare and set |
[in] | value | value of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[in] | cas | the cas value to compare |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1004 of file memcached.cpp.
References cas(), and PluginNotRegisterd.
Referenced by casByKey().
|
static |
Overwrites data for key in groupKey in the server as long as the cas value is still the same in the server. You can get the cas value by using the cas return value of Memcached::getByKey()
Type T has to be serializable into a QByteArray using QDataStream.
This method behaves in a similar nature as Memcached::cas(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupkey | key that specifies the server to write to |
[in] | key | key of object whose value to compare and set |
[in] | value | value of type T of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[in] | cas | the cas value to compare |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1056 of file memcached.h.
References cas(), and casByKey().
|
static |
Decrements the value of key by offset. If there is a valid pointer to value, the decremented value will be returned to it.
[in] | key | key to decrement |
[in] | offset | offset for decrement |
[out] | value | optional pointer to a variable that takes the decremented value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 839 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Drecrements the value of key in groupKey by offset. If there is a valid pointer to value, the decremented value will be returned to it. This method behaves in a similar nature as Memcached::decrement(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key that specifies the server to decrement the key on |
[in] | key | key to decrement |
[in] | offset | offset for decrement |
[out] | value | optional pointer to a variable that takes the decremented value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 868 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Decrements the value of key by offset. If the object specified by key does not exist, one of two things will happen: if the expiration value is Memcached::expirationNotAdd, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero. If there is a valid pointer to value, the created or decremented value will be returned to it.
[in] | key | key to decrement or initialize |
[in] | offset | offset for decrement |
[in] | initial | initial value if key does not exist |
[in] | expiration | expiration time in seconds |
[out] | value | optional pointer to a variable that takes the decremented or initialized value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 900 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Decrements the value of key in groupKey by offset. If the object specified by key does not exist, one of two things will happen: if the expiration value is Memcached::expirationNotAdd, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero. If there is a valid pointer to value, the created or decremented value will be returned to it.
This method behaves in a similar nature as Memcached::decrementWithInitial(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key that specifies the server to decrement or initialize the key on |
[in] | key | key to decrement or initialize |
[in] | offset | offset for decrement |
[in] | initial | initial value if key does not exist |
[in] | expiration | expiration time in seconds |
[out] | value | optional pointer to a variable that takes the decremented or initialized value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 931 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Converts the return type rt into human readable error string.
Definition at line 1316 of file memcached.cpp.
References AuthContinue, AuthFailure, AuthProblem, BadKeyProvided, Buffered, ClientError, ConnectionFailure, DataDoesNotExist, DataExists, Deleted, Deprecated, E2Big, End, Errno, Error, Failure, FetchNotFinished, HostLookupFailure, InvalidArguments, InvalidHostProtocol, KeyTooBig, MemoryAllocationFailure, NoServers, NotFound, NotStored, NotSupported, ParseError, ParseUserError, PartialRead, PluginNotRegisterd, ProtocolError, ReadFailure, ServerError, ServerMarkedDead, SomeErrors, Stat, Stored, Success, Timeout, Cutelyst::Context::translate(), UnknownReadFailure, UnknownStatKey, and WriteFailure.
|
static |
Checks if the key exists.
[in] | key | key to check |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
if the key exists; false
otherwise Definition at line 657 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Checks if the key exists in groupKey. This method behaves in a similar nature as Memcached::exist(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
groupKey | key that specifies the server to check on |
key | key to check |
returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
if the key exists; false
otherwise Definition at line 684 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Wipe cleans the contents of memcached servers. It will either do this immediately or expire the content based on the expiration time passed to the method (a value of zero causes an immediate flush). The operation is not atomic to multiple servers, just atomic to a single server. That is, it will flush the servers in the order that they were added.
[in] | expiration | time in seconds |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1070 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Used in conjunction with buffer requests enabled to flush all buffers by sending the buffered commands to the server for processing.
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1047 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Fetch an individial value from the server identified by key. The returned QByteArray will contain the data fetched from the server. If an error occured or if the key could not be found, the returned QByteArray will be null
. Use QByteArray::isNull() to check for this.
As this method returns a null
byte array if an error occured as well if the key could not be found, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | key | key of object whose value to fecth |
[out] | cas | optional pointer to a variable that takes the CAS value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
null
. Definition at line 489 of file memcached.cpp.
References cas(), and PluginNotRegisterd.
Referenced by get().
|
static |
Fetch an individial value of type T from the server identified by key. The returned type T will contain the data fetched from the server. If an error occured or if the key could not be found, the returned type T will be default constructed.
Type T has to be deserializable from a QByteArray using QDataStream.
As this method returns a default constructed type T if an error occured as well if the key could not be found, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | key | key of object whose value to fecth |
[out] | cas | optional pointer to a quint32 variable that takes the CAS value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
Definition at line 1023 of file memcached.h.
|
static |
Fetch an individial value from the server identified by key. The returned QByteArray will contain the data fetched from the server. If an error occured or if the key could not be found, the returned QByteArray will be null
. Use QByteArray::isNull() to check for this. This method behaves in a similar nature as Memcached::get(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
As this method returns a null
byte array if an error occured as well if the key could not be found, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | groupKey | key that specifies the server to fetch from |
[in] | key | key of object whose value to fecth |
[out] | cas | optional pointer to a variable that takes the CAS value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
null
. Definition at line 542 of file memcached.cpp.
References cas(), and PluginNotRegisterd.
Referenced by getByKey().
|
static |
Fetch an individial value from the server identified by key. The returned type T will contain the data fetched from the server. If an error occured or if the key could not be found, the returned type T will be default constructed. This method behaves in a similar nature as Memcached::get(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
Type T has to be deserializable from a QByteArray using QDataStream.
As this method returns a default constructed type T if an error occured as well if the key could not be found, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | groupKey | key that specifies the server to fetch from |
[in] | key | key of object whose value to fecth |
[out] | cas | optional pointer to a variable that takes the CAS value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
Definition at line 1035 of file memcached.h.
References cas(), and getByKey().
|
static |
Increments the value of key by offset. If there is a valid pointer to value, the incremented value will be returned to it.
[in] | key | key to increment |
[in] | offset | offset for increment |
[out] | value | optional pointer to a variable that takes the incremented value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 714 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Increments the value of key in groupKey by offset. If there is a valid pointer to value, the incremented value will be returned to it. This method behaves in a similar nature as Memcached::increment(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key that specifies the server to increment the key on |
[in] | key | key to increment |
[in] | offset | offset for increment |
[out] | value | optional pointer to a variable that takes the incremented value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 743 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Increments the value of key by offset. If the object specified by key does not exist, one of two things will happen: if the expiration value is Memcached::expirationNotAdd, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero. If there is a valid pointer to value, the created or incremented value will be returned to it.
[in] | key | key to increment or initialize |
[in] | offset | offset for increment |
[in] | initial | initial value if key does not exist |
[in] | expiration | expiration time in seconds |
[out] | value | optional pointer to a variable that takes the incremented or initialized value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 775 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Increments the value of key in groupKey by offset. If the object specified by key does not exist, one of two things will happen: if the expiration value is Memcached::expirationNotAdd, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero. If there is a valid pointer to value, the created or incremented value will be returned to it.
This method behaves in a similar nature as Memcached::incrementWithInitial(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key that specifies the server to increment the key on |
[in] | key | key to increment or initialize |
[in] | offset | offset for increment |
[in] | initial | initial value if key does not exist |
[in] | expiration | expiration time in seconds |
[out] | value | optional pointer to a variable that takes the incremented or initialized value |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 806 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Fetch multiple values from the server identified by a list of keys. If a pointer for the casValues is provided, keys and their cas values will be written to it.
As this might return an empty QHash if nothing has been found or if an error occured, you can use the returnType pointer to determine the reason.
[in] | keys | list of keys to fetch from the server |
[out] | casValues | optional pointer to a QHash that will contain keys and their cas values |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
Definition at line 1093 of file memcached.cpp.
References BadKeyProvided, and PluginNotRegisterd.
Referenced by mget().
|
static |
Fetch multiple values of type T from the server identified by a list of keys. If a pointer for the casValues is provided, keys and their cas values are written to it.
As this might return an empty QHash if nothing has been found or if an error occured, you can use the returnType pointer to determine the reason.
Type T has to be deserializable from a QByteArray using QDataStream.
[in] | keys | list of keys to fetch from the server |
[out] | casValues | optional pointer to a QHash that will contain keys and their cas values |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
Definition at line 1065 of file memcached.h.
References mget().
|
static |
Fetch multiple values from the server specified by groupKey identified by a list of keys. If a pointer for the casValues is provided, keys and their cas values will be written to it.
As this might return an empty QHash if nothing has been found or if an error occured, you can use the returnType pointer to determine the reason.
This method behaves in a similar nature as Memcached::mget(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key to specify the server to fetch values from |
[in] | keys | list of keys to fetch from the server |
[out] | casValues | optional pointer to a QHash that will contain keys and their cas values |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
Definition at line 1168 of file memcached.cpp.
References BadKeyProvided, and PluginNotRegisterd.
Referenced by mgetByKey().
|
static |
Fetch multiple values of type T from the server specified by groupKey identified by a list of keys. If a pointer for the casValues is provided, keys and their cas values will be written to it.
As this might return an empty QHash if nothing has been found or if an error occured, you can use the returnType pointer to determine the reason.
Type T has to be deserializable from a QByteArray using QDataStream.
This method behaves in a similar nature as Memcached::mget(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key to specify the server to fetch values from |
[in] | keys | list of keys to fetch from the server |
[out] | casValues | optional pointer to a QHash that will contain keys and their cas values |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
Definition at line 1083 of file memcached.h.
References mgetByKey().
|
static |
Directly deletes a particular key.
[in] | key | key of object to delete |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 598 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Directly deletes a particular key in groupKey. This method behaves in a similar nature as Memcached::remove(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key that specifies the server to delete from |
[in] | key | key of object to delete |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 626 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Replaces the data of key on the server with value. If the key ist not found on the server an error occures and false
will be returned.
As this method returns false
if the key can not be found on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | key | key of object whose value to replace |
[in] | value | value to replace object on server with |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 408 of file memcached.cpp.
References PluginNotRegisterd.
Referenced by replace().
|
static |
Replaces the data of key on the server with value of type T. If the key ist not found on the server an error occures and false
will be returned.
Type T has to be serializable into a QByteArray using QDataStream.
As this method returns false
if the key can not be found on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | key | key of object whose value to replace |
[in] | value | value to replace object on server with |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1005 of file memcached.h.
References replace().
|
static |
Replaces the data of key on the server with value. If the key ist not found on the server an error occures and false
will be returned. This method is functionally equivalent to Memcached::replace(), except that the free-form groupKey can be used to map the key to a specific server. This allows related items to be grouped together on a single server for efficiency.
As this method returns false
if the key can not be found on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | groupKey | key that specifies the server to write to |
[in] | key | key of object whose value to replace |
[in] | value | value to replace object on server with |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 447 of file memcached.cpp.
References PluginNotRegisterd.
Referenced by replaceByKey().
|
static |
Replaces the data of key on the server with value of Type T. If the key ist not found on the server an error occures and false
will be returned. This method is functionally equivalent to Memcached::replace(), except that the free-form groupKey can be used to map the key to a specific server. This allows related items to be grouped together on a single server for efficiency.
Type T has to be serializable into a QByteArray using QDataStream.
As this method returns false
if the key can not be found on the server, you can use the value of the returnType to determine the reason. Other than with other errors, failing because of not found key will not be logged.
[in] | groupKey | key that specifies the server to write to |
[in] | key | key of object whose value to replace |
[in] | value | value to replace object on server with |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1014 of file memcached.h.
References replaceByKey().
|
static |
Writes the value to the memcached server using key. If the key already exists it will overwrite what is on the server. If the object does not exist it will be written.
[in] | key | key of object whose value to set |
[in] | value | value of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 246 of file memcached.cpp.
References PluginNotRegisterd.
Referenced by set().
|
static |
Writes the value of type T to the memcached server using key. If the key already exists it will overwrite what is on the server. If the object does not exist it will be written.
Type T has to be serializable into a QByteArray using QDataStream.
[in] | key | key of object whose value to set |
[in] | value | value of type T of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 969 of file memcached.h.
References set().
|
static |
Writes the value to the memcached server using key. If the key already exists it will overwrite what is on the server. If the object does not exist it will be written. This method is functionally equivalent to Memcached::set(), except that the free-form groupKey can be used to map the key to a specific server. This allows related items to be grouped together on a single server for efficiency.
[in] | groupKey | key that specifies the server to write to |
[in] | key | key of object whose value to set |
[in] | value | value of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 285 of file memcached.cpp.
References PluginNotRegisterd.
Referenced by setByKey().
|
static |
Writes the value of type T to the memcached server using key. If the key already exists it will overwrite what is on the server. If the object does not exist it will be written. This method is functionally equivalent to Memcached::set(), except that the free-form groupKey can be used to map the key to a specific server. This allows related items to be grouped together on a single server for efficiency.
Type T has to be serializable into a QByteArray using QDataStream.
[in] | groupKey | key that specifies the server to write to |
[in] | key | key of object whose value to set |
[in] | value | value of type T of object to write to server |
[in] | expiration | time in seconds to keep the object stored in the server |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 978 of file memcached.h.
References setByKey().
void Memcached::setDefaultConfig | ( | const QVariantMap & | defaultConfig | ) |
Sets default configuration values for configuration keys that are not set in the Cutelyst configuratoin file.
Definition at line 47 of file memcached.cpp.
|
overrideprotectedvirtual |
Reads the configuration and sets up the plugin.
Reimplemented from Cutelyst::Plugin.
Definition at line 53 of file memcached.cpp.
References Cutelyst::Engine::config(), Cutelyst::Application::engine(), Cutelyst::Application::loadTranslations(), and Cutelyst::Application::postForked().
|
static |
Updates the expiration time on an existing key.
[in] | key | key whose expiration time to update |
[in] | expiration | new expiration time in seconds |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1257 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Updates the expiration time on an existing key in group groupKey.
This method behaves in a similar nature as Memcached::touch(). The difference is that it takes a groupKey that is used for determining which server an object was stored if key partitioning was used for storage.
[in] | groupKey | key to specify the server to update the key on |
[in] | key | key whose expiration time to update |
[in] | expiration | new expiration time in seconds |
[out] | returnType | optional pointer to a MemcachedReturnType variable that takes the return type of the operation |
true
on success; false
otherwise Definition at line 1285 of file memcached.cpp.
References PluginNotRegisterd.
|
static |
Expiration time constant that can be used in the increment/decrement with initial methods. @ sa incrementWithInitial() incrementWithInitialByKey() decrementWithInitial() decrementWithInitialByKey()
Definition at line 585 of file memcached.h.