cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Cutelyst::Memcached Class Reference

Cutelyst Memcached plugin. More...

#include <Cutelyst/Plugins/Memcached/Memcached>

Inheritance diagram for Cutelyst::Memcached:

Public Types

enum class  ReturnType {
  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)
 
 Memcached (Application *parent, const QVariantMap &defaultConfig)
 
 ~Memcached () override
 
void setDefaultConfig (const QVariantMap &defaultConfig)
 
- Public Member Functions inherited from Cutelyst::Plugin
 Plugin (Application *parent)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static bool add (QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool add (QByteArrayView key, const QByteArray &value, time_t expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool add (QByteArrayView key, const T &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool add (QByteArrayView key, const T &value, time_t expiration, ReturnType *returnType=nullptr)
 
static bool addByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool addByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, time_t expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool addByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool addByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, time_t expiration, ReturnType *returnType=nullptr)
 
static bool cas (QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
static bool cas (QByteArrayView key, const QByteArray &value, time_t expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
template<typename T >
static bool cas (QByteArrayView key, const T &value, std::chrono::seconds expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
template<typename T >
static bool cas (QByteArrayView key, const T &value, time_t expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
static bool casByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
static bool casByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, time_t expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
template<typename T >
static bool casByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, std::chrono::seconds expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
template<typename T >
static bool casByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, time_t expiration, uint64_t cas, ReturnType *returnType=nullptr)
 
static bool decrement (QByteArrayView key, uint32_t offset, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool decrementByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t offset, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool decrementWithInitial (QByteArrayView key, uint64_t offset, uint64_t initial, std::chrono::seconds expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool decrementWithInitial (QByteArrayView key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool decrementWithInitialByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t offset, uint64_t initial, std::chrono::seconds expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool decrementWithInitialByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static QString errorString (Context *c, ReturnType rt)
 
static bool exist (QByteArrayView key, ReturnType *returnType=nullptr)
 
static bool existByKey (QByteArrayView groupKey, QByteArrayView key, ReturnType *returnType=nullptr)
 
static bool flush (std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool flush (time_t expiration, ReturnType *returnType=nullptr)
 
static bool flushBuffers (ReturnType *returnType=nullptr)
 
static QByteArray get (QByteArrayView key, uint64_t *cas=nullptr, ReturnType *returnType=nullptr)
 
template<typename T >
static T get (QByteArrayView key, uint64_t *cas=nullptr, ReturnType *returnType=nullptr)
 
static QByteArray getByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t *cas=nullptr, ReturnType *returnType=nullptr)
 
template<typename T >
static T getByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t *cas=nullptr, ReturnType *returnType=nullptr)
 
static bool increment (QByteArrayView key, uint32_t offset, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool incrementByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t offset, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool incrementWithInitial (QByteArrayView key, uint64_t offset, uint64_t initial, std::chrono::seconds expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool incrementWithInitial (QByteArrayView key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool incrementWithInitialByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t offset, uint64_t initial, std::chrono::seconds expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static bool incrementWithInitialByKey (QByteArrayView groupKey, QByteArrayView key, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value=nullptr, ReturnType *returnType=nullptr)
 
static QVersionNumber libMemcachedVersion ()
 Returns the version of the currently used libmemcached.
 
static QHash< QByteArray, QByteArraymget (const QByteArrayList &keys, QHash< QByteArray, uint64_t > *casValues=nullptr, ReturnType *returnType=nullptr)
 
template<typename T >
static QHash< QByteArray, T > mget (const QByteArrayList &keys, QHash< QByteArray, uint64_t > *casValues=nullptr, ReturnType *returnType=nullptr)
 
static QHash< QByteArray, QByteArraymgetByKey (QByteArrayView groupKey, const QByteArrayList &keys, QHash< QByteArray, uint64_t > *casValues=nullptr, ReturnType *returnType=nullptr)
 
template<typename T >
static QHash< QByteArray, T > mgetByKey (QByteArrayView groupKey, const QByteArrayList &keys, QHash< QByteArray, uint64_t > *casValues=nullptr, ReturnType *returnType=nullptr)
 
static bool remove (QByteArrayView key, ReturnType *returnType=nullptr)
 
static bool removeByKey (QByteArrayView groupKey, QByteArrayView key, ReturnType *returnType=nullptr)
 
static bool replace (QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool replace (QByteArrayView key, const QByteArray &value, time_t expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool replace (QByteArrayView key, const T &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool replace (QByteArrayView key, const T &value, time_t expiration, ReturnType *returnType=nullptr)
 
static bool replaceByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool replaceByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, time_t expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool replaceByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool replaceByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, time_t expiration, ReturnType *returnType=nullptr)
 
static bool set (QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool set (QByteArrayView key, const QByteArray &value, time_t expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool set (QByteArrayView key, const T &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool set (QByteArrayView key, const T &value, time_t expiration, ReturnType *returnType=nullptr)
 
static bool setByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool setByKey (QByteArrayView groupKey, QByteArrayView key, const QByteArray &value, time_t expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool setByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
template<typename T >
static bool setByKey (QByteArrayView groupKey, QByteArrayView key, const T &value, time_t expiration, ReturnType *returnType=nullptr)
 
static bool touch (QByteArrayView key, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool touch (QByteArrayView key, time_t expiration, ReturnType *returnType=nullptr)
 
static bool touchByKey (QByteArrayView groupKey, QByteArrayView key, std::chrono::seconds expiration, ReturnType *returnType=nullptr)
 
static bool touchByKey (QByteArrayView groupKey, QByteArrayView key, time_t expiration, ReturnType *returnType=nullptr)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Static Public Attributes

static const time_t expirationNotAdd
 
static const std::chrono::seconds expirationNotAddDuration
 

Protected Member Functions

bool setup (Application *app) override
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Properties inherited from QObject
 objectName
 

Detailed Description

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.

Configuration

The Memcached plugin can be configured in the application 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:

compression

Type: bool
Default: fase

Enables compression of input values based on qCompress / zlib.

compression_level

Type: integer
Default: -1

The compression level used by qCompress(). Valid values are between 0 and 9, with 9 corresponding to the greatest compression. The value 0 corresponds to no compression at all. The default value is -1, which specifies zlib’s default compression.

compression_threshold

Type: integer
Default: 100

The compression size threshold in bytes. Only input values bigger than the threshold will be compressed.

encryption_key

Type: string
Default: empty

If set and not empty, AES encryption will be enabled for storing data on the memcached servers.

sasl_user

Type: string
Default: empty

If set and not empty, SASL authentication will be used to authenticate with the memcached server(s). Note that SASL support has to be enabled when building libmemcached.

sasl_password

Type: string
Default: empty

Password used for the SASL authentication with the memcached server(s).

Note
If you want to use non-ASCII key names, you have to enable the binary protocol.

To set default values directly in your application, use setDefaultConfig() or the overloaded constructor taking default values. Configuration values that can not be found in the application configuration file will be looked up for default values in that QVariantMap.

Configuration example

[Cutelyst_Memcached_Plugin]
servers=cache.example.com,11211,2;/path/to/memcached.sock,1
binary_protocol=true
namespace=foobar

Expiration times

Expiration times are set in seconds. If the value is bigger than 30 days, it is interpreted as a unix timestamp.

Logging and return types

Messages from this plugin are logged to the logging category cutelyst.plugin.memcached. All methods provide the possibility to specify a pointer to a Memcached::ReturnType variable that can provide further information about occurred errors if methods return false or empty results.

See also
Logging with Cutelyst

Usage example

#include <Cutelyst/Plugins/Memcached/Memcached>
bool MyCutelystApp::init()
{
// other initialization stuff
// ...
new Memcached(this);
// maybe more initialization stuff
//...
}
void MyController::index(Context *c)
{
QVariantList myData = Memcached::get<QVariantList>(QStringLiteral("myKey"));
if (myData.empty()) {
QSqlQuery q = CPreparedSqlQuery(QStringLiteral("SELECT * FROM myTable"));
if (q.exec()) {
myData = Sql::queryToHashList(q);
if (!myData.empty()) {
Memcached::set(QStringLiteral("myKey"), myData, 900);
}
}
}
// present your data
// ...
}
The Cutelyst Context.
Definition context.h:42
Cutelyst Memcached plugin.
Definition memcached.h:168
static bool set(QByteArrayView key, const QByteArray &value, time_t expiration, ReturnType *returnType=nullptr)
CUTELYST_PLUGIN_UTILS_SQL_EXPORT QVariantList queryToHashList(QSqlQuery &query)
Definition sql.cpp:33
#define CPreparedSqlQuery(str)
Definition sql.h:234
bool exec()

Build requirements

To build this plugin you need the development and header files for libmemcached and run cmake with -DPLUGIN_MEMCACHED:BOOL=ON.

Unit test

Enabling the build of the Memcached plugin will also enable the unit tests for this plugin. By default, the unit test will start its own memcached instance. Alternatively you can set the CUTELYST_MEMCACHED_TEST_SERVERS environment variable in your build environment to define different servers that you have to start by yourself. 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, export the following environment variable befor running the tests:

export CUTELYST_MEMCACHED_TEST_SERVERS=localhost;/tmp/memcached.sock
Since
Cutelyst 1.11.0

Definition at line 166 of file memcached.h.

Member Enumeration Documentation

◆ ReturnType

Return types for memcached operations.

Enumerator
Success 

The request was successfully executed.

Failure 

An unknown failure has occurred in the server.

HostLookupFailure 

A DNS failure has occurred.

ConnectionFailure 

An unknown error has occurred while trying to connect to a server.

WriteFailure 

An error has occurred 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 occurred internally.

ServerError 

An unknown error has occurred in the server.

Error 

A general error occurred.

DataExists 

The data requested with the given key was found.

DataDoesNotExist 

The data requested with the given key 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 operation 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 occurred 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 196 of file memcached.h.

Constructor & Destructor Documentation

◆ Memcached() [1/2]

Memcached::Memcached ( Application parent)

Constructs a new Memcached object with the given parent.

Definition at line 25 of file memcached.cpp.

◆ Memcached() [2/2]

Memcached::Memcached ( Application parent,
const QVariantMap &  defaultConfig 
)

Contructs a new Memcached object with the given parent and defaultConfig.

Use the defaultConfig to set default values for the configuration entries from the configuration file.

Since
Cutelyst 4.0.0

Definition at line 31 of file memcached.cpp.

◆ ~Memcached()

Memcached::~Memcached ( )
overridedefault

Deconstructs the Memcached object.

Member Function Documentation

◆ add() [1/4]

bool Cutelyst::Memcached::add ( QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1489 of file memcached.h.

References add().

◆ add() [2/4]

bool Memcached::add ( QByteArrayView  key,
const QByteArray value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]keykey of object whose value to add
[in]valuevalue of object to add to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 329 of file memcached.cpp.

References QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by add(), and add().

◆ add() [3/4]

template<typename T >
bool Cutelyst::Memcached::add ( QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1507 of file memcached.h.

◆ add() [4/4]

template<typename T >
bool Cutelyst::Memcached::add ( QByteArrayView  key,
const T &  value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]keykey of object whose value to add
[in]valuevalue of type T of object to add to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1498 of file memcached.h.

References add(), and QIODeviceBase::WriteOnly.

◆ addByKey() [1/4]

bool Cutelyst::Memcached::addByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1515 of file memcached.h.

References addByKey().

◆ addByKey() [2/4]

bool Memcached::addByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to add
[in]valuevalue of object to add to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 361 of file memcached.cpp.

References QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by addByKey(), and addByKey().

◆ addByKey() [3/4]

template<typename T >
bool Cutelyst::Memcached::addByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1538 of file memcached.h.

◆ addByKey() [4/4]

template<typename T >
bool Cutelyst::Memcached::addByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to add
[in]valuevalue of object to add to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1525 of file memcached.h.

References addByKey(), and QIODeviceBase::WriteOnly.

◆ cas() [1/4]

bool Cutelyst::Memcached::cas ( QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1681 of file memcached.h.

References cas().

◆ cas() [2/4]

bool Memcached::cas ( QByteArrayView  key,
const QByteArray value,
time_t  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
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()

Parameters
[in]keykey of object whose value to compare and set
[in]valuevalue of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[in]casthe cas value to compare
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 877 of file memcached.cpp.

References cas(), QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by cas(), cas(), cas(), cas(), casByKey(), casByKey(), casByKey(), casByKey(), get(), and getByKey().

◆ cas() [3/4]

template<typename T >
bool Cutelyst::Memcached::cas ( QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1704 of file memcached.h.

References cas().

◆ cas() [4/4]

template<typename T >
bool Cutelyst::Memcached::cas ( QByteArrayView  key,
const T &  value,
time_t  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]keykey of object whose value to compare and set
[in]valuevalue of type T of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[in]casthe cas value to compare
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1691 of file memcached.h.

References cas(), and QIODeviceBase::WriteOnly.

◆ casByKey() [1/4]

bool Cutelyst::Memcached::casByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1713 of file memcached.h.

References cas(), and casByKey().

◆ casByKey() [2/4]

bool Memcached::casByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
time_t  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to compare and set
[in]valuevalue of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[in]casthe cas value to compare
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 911 of file memcached.cpp.

References cas(), QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by casByKey(), and casByKey().

◆ casByKey() [3/4]

template<typename T >
bool Cutelyst::Memcached::casByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1738 of file memcached.h.

References cas().

◆ casByKey() [4/4]

template<typename T >
bool Cutelyst::Memcached::casByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
time_t  expiration,
uint64_t  cas,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to compare and set
[in]valuevalue of type T of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[in]casthe cas value to compare
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1724 of file memcached.h.

References cas(), casByKey(), and QIODeviceBase::WriteOnly.

◆ decrement()

bool Memcached::decrement ( QByteArrayView  key,
uint32_t  offset,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
static

Decrements the value of key by offset. If there is a valid pointer to value, the decremented value will be returned to it.

Note
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]keykey to decrement
[in]offsetoffset for decrement
[out]valueoptional pointer to a variable that takes the decremented value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 760 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ decrementByKey()

bool Memcached::decrementByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t  offset,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
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.

Note
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]groupKeykey that specifies the server to decrement the key on
[in]keykey to decrement
[in]offsetoffset for decrement
[out]valueoptional pointer to a variable that takes the decremented value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 784 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ decrementWithInitial() [1/2]

bool Cutelyst::Memcached::decrementWithInitial ( QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
std::chrono::seconds  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1631 of file memcached.h.

References QByteArrayView::count(), and decrementWithInitial().

◆ decrementWithInitial() [2/2]

bool Memcached::decrementWithInitial ( QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
time_t  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
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.

Note
This method will only work when using the binary protocol.
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]keykey to decrement or initialize
[in]offsetoffset for decrement
[in]initialinitial value if key does not exist
[in]expirationexpiration time in seconds
[out]valueoptional pointer to a variable that takes the decremented or initialized value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 815 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

Referenced by decrementWithInitial().

◆ decrementWithInitialByKey() [1/2]

bool Cutelyst::Memcached::decrementWithInitialByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
std::chrono::seconds  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1642 of file memcached.h.

References QByteArrayView::count(), and decrementWithInitialByKey().

◆ decrementWithInitialByKey() [2/2]

bool Memcached::decrementWithInitialByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
time_t  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
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.

Note
This method will only work when using the binary protocol.
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]groupKeykey that specifies the server to decrement or initialize the key on
[in]keykey to decrement or initialize
[in]offsetoffset for decrement
[in]initialinitial value if key does not exist
[in]expirationexpiration time in seconds
[out]valueoptional pointer to a variable that takes the decremented or initialized value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 842 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

Referenced by decrementWithInitialByKey().

◆ errorString()

◆ exist()

bool Memcached::exist ( QByteArrayView  key,
ReturnType returnType = nullptr 
)
static

Checks if the key exists.

Parameters
[in]keykey to check
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true if the key exists; false otherwise

Definition at line 601 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ existByKey()

bool Memcached::existByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
ReturnType returnType = nullptr 
)
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.

Parameters
groupKeykey that specifies the server to check on
keykey to check
returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true if the key exists; false otherwise

Definition at line 621 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ flush() [1/2]

bool Cutelyst::Memcached::flush ( std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1748 of file memcached.h.

References flush().

◆ flush() [2/2]

bool Memcached::flush ( time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]expirationtime in seconds
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 969 of file memcached.cpp.

Referenced by flush().

◆ flushBuffers()

bool Memcached::flushBuffers ( ReturnType returnType = nullptr)
static

Used in conjunction with buffer requests enabled to flush all buffers by sending the buffered commands to the server for processing.

Parameters
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 949 of file memcached.cpp.

◆ get() [1/2]

QByteArray Memcached::get ( QByteArrayView  key,
uint64_t *  cas = nullptr,
ReturnType returnType = nullptr 
)
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 occurred 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 occurred 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.

Parameters
[in]keykey of object whose value to fecth
[out]casoptional pointer to a variable that takes the CAS value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
QByteArray containing the data fetched from the server; if an error occurred or the key has not been found, this will be null.

Definition at line 464 of file memcached.cpp.

References cas(), QByteArrayView::constData(), QByteArray::push_back(), and QByteArrayView::size().

Referenced by get().

◆ get() [2/2]

template<typename T >
T Cutelyst::Memcached::get ( QByteArrayView  key,
uint64_t *  cas = nullptr,
ReturnType returnType = nullptr 
)
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 occurred 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 occurred 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.

Usage example
void MyController::index(Context *c)
{
//...
QVariantList list = Memcached::get<QVariantList>(QStringLiteral("MyKey"));
//...
}
Parameters
[in]keykey of object whose value to fecth
[out]casoptional pointer to a quint32 variable that takes the CAS value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
type T containing the data fetched from the server; if an error occurred or the key has not been found, this will be a default constructed value

Definition at line 1655 of file memcached.h.

References cas(), get(), QByteArray::isEmpty(), and QIODeviceBase::ReadOnly.

◆ getByKey() [1/2]

QByteArray Memcached::getByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t *  cas = nullptr,
ReturnType returnType = nullptr 
)
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 occurred 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 occurred 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.

Parameters
[in]groupKeykey that specifies the server to fetch from
[in]keykey of object whose value to fecth
[out]casoptional pointer to a variable that takes the CAS value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
QByteArray containing the data fetched from the server; if an error occurred or the key has not been found, this will be null.

Definition at line 509 of file memcached.cpp.

References cas(), QByteArrayView::constData(), QByteArray::push_back(), and QByteArrayView::size().

Referenced by getByKey().

◆ getByKey() [2/2]

template<typename T >
T Cutelyst::Memcached::getByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t *  cas = nullptr,
ReturnType returnType = nullptr 
)
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 occurred 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 occurred 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.

Usage example
void MyController::index(Context *c)
{
//...
QVariantList list = Memcached::getByKey<QVariantList>(QStringLiteral("MyGroup"),
QStringLiteral("MyKey"));
//...
}
Parameters
[in]groupKeykey that specifies the server to fetch from
[in]keykey of object whose value to fecth
[out]casoptional pointer to a variable that takes the CAS value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
type T containing the data fetched from the server; if an error occurred or the key has not been found, this will be a default constructed value

Definition at line 1667 of file memcached.h.

References cas(), getByKey(), QByteArray::isEmpty(), and QIODeviceBase::ReadOnly.

◆ increment()

bool Memcached::increment ( QByteArrayView  key,
uint32_t  offset,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
static

Increments the value of key by offset. If there is a valid pointer to value, the incremented value will be returned to it.

Note
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]keykey to increment
[in]offsetoffset for increment
[out]valueoptional pointer to a variable that takes the incremented value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 643 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ incrementByKey()

bool Memcached::incrementByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t  offset,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
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.

Note
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]groupKeykey that specifies the server to increment the key on
[in]keykey to increment
[in]offsetoffset for increment
[out]valueoptional pointer to a variable that takes the incremented value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 667 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ incrementWithInitial() [1/2]

bool Cutelyst::Memcached::incrementWithInitial ( QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
std::chrono::seconds  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1608 of file memcached.h.

References QByteArrayView::count(), and incrementWithInitial().

◆ incrementWithInitial() [2/2]

bool Memcached::incrementWithInitial ( QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
time_t  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
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.

Note
This method will only work when using the binary protocol.
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]keykey to increment or initialize
[in]offsetoffset for increment
[in]initialinitial value if key does not exist
[in]expirationexpiration time in seconds
[out]valueoptional pointer to a variable that takes the incremented or initialized value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 698 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

Referenced by incrementWithInitial().

◆ incrementWithInitialByKey() [1/2]

bool Cutelyst::Memcached::incrementWithInitialByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
std::chrono::seconds  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1619 of file memcached.h.

References QByteArrayView::count(), and incrementWithInitialByKey().

◆ incrementWithInitialByKey() [2/2]

bool Memcached::incrementWithInitialByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
uint64_t  offset,
uint64_t  initial,
time_t  expiration,
uint64_t *  value = nullptr,
ReturnType returnType = nullptr 
)
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.

Note
This method will only work when using the binary protocol.
Be aware that the memcached server does not detect overflow and underflow.
This function does not work if encryption is enabled.
Parameters
[in]groupKeykey that specifies the server to increment the key on
[in]keykey to increment or initialize
[in]offsetoffset for increment
[in]initialinitial value if key does not exist
[in]expirationexpiration time in seconds
[out]valueoptional pointer to a variable that takes the incremented or initialized value
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 725 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

Referenced by incrementWithInitialByKey().

◆ libMemcachedVersion()

QVersionNumber Memcached::libMemcachedVersion ( )
static

Definition at line 1326 of file memcached.cpp.

References QVersionNumber::fromString().

◆ mget() [1/2]

QHash< QByteArray, QByteArray > Memcached::mget ( const QByteArrayList keys,
QHash< QByteArray, uint64_t > *  casValues = nullptr,
ReturnType returnType = nullptr 
)
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 occurred, you can use the returnType pointer to determine the reason.

Parameters
[in]keyslist of keys to fetch from the server
[out]casValuesoptional pointer to a QHash that will contain keys and their cas values
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
QHash containing the keys and values

Definition at line 989 of file memcached.cpp.

References BadKeyProvided, QList::empty(), QHash::insert(), QHash::reserve(), and QList::size().

Referenced by mget().

◆ mget() [2/2]

template<typename T >
QHash< QByteArray, T > Cutelyst::Memcached::mget ( const QByteArrayList keys,
QHash< QByteArray, uint64_t > *  casValues = nullptr,
ReturnType returnType = nullptr 
)
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 occurred, you can use the returnType pointer to determine the reason.

Type T has to be deserializable from a QByteArray using QDataStream.

Parameters
[in]keyslist of keys to fetch from the server
[out]casValuesoptional pointer to a QHash that will contain keys and their cas values
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
QHash containing the keys and values

Definition at line 1754 of file memcached.h.

References QHash::constBegin(), QHash::constEnd(), QHash::empty(), QHash::insert(), and mget().

◆ mgetByKey() [1/2]

QHash< QByteArray, QByteArray > Memcached::mgetByKey ( QByteArrayView  groupKey,
const QByteArrayList keys,
QHash< QByteArray, uint64_t > *  casValues = nullptr,
ReturnType returnType = nullptr 
)
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 occurred, 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.

Parameters
[in]groupKeykey to specify the server to fetch values from
[in]keyslist of keys to fetch from the server
[out]casValuesoptional pointer to a QHash that will contain keys and their cas values
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
QHash containing the keys and values

Definition at line 1053 of file memcached.cpp.

References BadKeyProvided, QByteArrayView::constData(), QList::empty(), QHash::insert(), QByteArrayView::isEmpty(), QHash::reserve(), QByteArrayView::size(), and QList::size().

Referenced by mgetByKey().

◆ mgetByKey() [2/2]

template<typename T >
QHash< QByteArray, T > Cutelyst::Memcached::mgetByKey ( QByteArrayView  groupKey,
const QByteArrayList keys,
QHash< QByteArray, uint64_t > *  casValues = nullptr,
ReturnType returnType = nullptr 
)
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 occurred, 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.

Parameters
[in]groupKeykey to specify the server to fetch values from
[in]keyslist of keys to fetch from the server
[out]casValuesoptional pointer to a QHash that will contain keys and their cas values
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
QHash containing the keys and values

Definition at line 1774 of file memcached.h.

References QHash::constBegin(), QHash::constEnd(), QHash::empty(), QHash::insert(), and mgetByKey().

◆ remove()

bool Memcached::remove ( QByteArrayView  key,
ReturnType returnType = nullptr 
)
static

Directly deletes a particular key.

Parameters
[in]keykey of object to delete
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 558 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ removeByKey()

bool Memcached::removeByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to delete from
[in]keykey of object to delete
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 579 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

◆ replace() [1/4]

bool Cutelyst::Memcached::replace ( QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1547 of file memcached.h.

References replace().

◆ replace() [2/4]

bool Memcached::replace ( QByteArrayView  key,
const QByteArray value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]keykey of object whose value to replace
[in]valuevalue to replace object on server with
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 396 of file memcached.cpp.

References QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by replace(), and replace().

◆ replace() [3/4]

template<typename T >
bool Cutelyst::Memcached::replace ( QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1568 of file memcached.h.

◆ replace() [4/4]

template<typename T >
bool Cutelyst::Memcached::replace ( QByteArrayView  key,
const T &  value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]keykey of object whose value to replace
[in]valuevalue to replace object on server with
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1556 of file memcached.h.

References replace(), and QIODeviceBase::WriteOnly.

◆ replaceByKey() [1/4]

bool Cutelyst::Memcached::replaceByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1576 of file memcached.h.

References replaceByKey().

◆ replaceByKey() [2/4]

bool Memcached::replaceByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to replace
[in]valuevalue to replace object on server with
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 428 of file memcached.cpp.

References QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by replaceByKey(), and replaceByKey().

◆ replaceByKey() [3/4]

template<typename T >
bool Cutelyst::Memcached::replaceByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1599 of file memcached.h.

◆ replaceByKey() [4/4]

template<typename T >
bool Cutelyst::Memcached::replaceByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to replace
[in]valuevalue to replace object on server with
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1586 of file memcached.h.

References replaceByKey(), and QIODeviceBase::WriteOnly.

◆ set() [1/4]

bool Cutelyst::Memcached::set ( QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1431 of file memcached.h.

References set().

◆ set() [2/4]

bool Memcached::set ( QByteArrayView  key,
const QByteArray value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]keykey of object whose value to set
[in]valuevalue of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 261 of file memcached.cpp.

References QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by set(), and set().

◆ set() [3/4]

template<typename T >
bool Cutelyst::Memcached::set ( QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1449 of file memcached.h.

◆ set() [4/4]

template<typename T >
bool Cutelyst::Memcached::set ( QByteArrayView  key,
const T &  value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]keykey of object whose value to set
[in]valuevalue of type T of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1440 of file memcached.h.

References set(), and QIODeviceBase::WriteOnly.

◆ setByKey() [1/4]

bool Cutelyst::Memcached::setByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1457 of file memcached.h.

References setByKey().

◆ setByKey() [2/4]

bool Memcached::setByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const QByteArray value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to set
[in]valuevalue of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 293 of file memcached.cpp.

References QByteArray::constData(), QByteArrayView::constData(), QByteArray::size(), and QByteArrayView::size().

Referenced by setByKey(), and setByKey().

◆ setByKey() [3/4]

template<typename T >
bool Cutelyst::Memcached::setByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1480 of file memcached.h.

◆ setByKey() [4/4]

template<typename T >
bool Cutelyst::Memcached::setByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
const T &  value,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey that specifies the server to write to
[in]keykey of object whose value to set
[in]valuevalue of type T of object to write to server
[in]expirationtime in seconds to keep the object stored in the server
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1467 of file memcached.h.

References setByKey(), and QIODeviceBase::WriteOnly.

◆ setDefaultConfig()

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 39 of file memcached.cpp.

◆ setup()

◆ touch() [1/2]

bool Cutelyst::Memcached::touch ( QByteArrayView  key,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1796 of file memcached.h.

References QByteArrayView::count(), and touch().

◆ touch() [2/2]

bool Memcached::touch ( QByteArrayView  key,
time_t  expiration,
ReturnType returnType = nullptr 
)
static

Updates the expiration time on an existing key.

Parameters
[in]keykey whose expiration time to update
[in]expirationnew expiration time in seconds
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1132 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

Referenced by touch().

◆ touchByKey() [1/2]

bool Cutelyst::Memcached::touchByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
std::chrono::seconds  expiration,
ReturnType returnType = nullptr 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Cutelyst 4.0.0

Definition at line 1801 of file memcached.h.

References QByteArrayView::count(), and touchByKey().

◆ touchByKey() [2/2]

bool Memcached::touchByKey ( QByteArrayView  groupKey,
QByteArrayView  key,
time_t  expiration,
ReturnType returnType = nullptr 
)
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.

Parameters
[in]groupKeykey to specify the server to update the key on
[in]keykey whose expiration time to update
[in]expirationnew expiration time in seconds
[out]returnTypeoptional pointer to a ReturnType variable that takes the return type of the operation
Returns
true on success; false otherwise

Definition at line 1154 of file memcached.cpp.

References QByteArrayView::constData(), and QByteArrayView::size().

Referenced by touchByKey().

Member Data Documentation

◆ expirationNotAdd

const time_t Memcached::expirationNotAdd
static

Expiration time constant that can be used in the increment/decrement with initial methods.

See also
incrementWithInitial() incrementWithInitialByKey() decrementWithInitial() decrementWithInitialByKey()

Definition at line 830 of file memcached.h.

◆ expirationNotAddDuration

const std::chrono::seconds Memcached::expirationNotAddDuration
static

Expiration duration constant that can be used in the increment/decrement with initial methods.

See also
incrementWithInitial() incrementWithInitialByKey() decrementWithInitial() decrementWithInitialByKey()
Since
Cutelyst 4.0.0

Definition at line 839 of file memcached.h.