7 #include <Cutelyst/Plugins/memcached_export.h>
8 #include <Cutelyst/plugin.h>
11 #include <QDataStream>
12 #include <QVersionNumber>
17 class MemcachedPrivate;
196 enum class ReturnType {
216 MemoryAllocationFailure,
248 ServerTemporaryDisabled,
249 ServerMemoryAllocationFailure,
254 Q_ENUM(Memcached::ReturnType)
260 void setDefaultConfig(
const QVariantMap &defaultConfig);
277 ReturnType *returnType =
nullptr);
285 std::chrono::seconds expiration,
286 ReturnType *returnType =
nullptr);
302 template <
typename T>
306 ReturnType *returnType =
nullptr);
312 template <
typename T>
315 std::chrono::seconds expiration,
316 ReturnType *returnType =
nullptr);
338 ReturnType *returnType =
nullptr);
347 std::chrono::seconds expiration,
348 ReturnType *returnType =
nullptr);
367 template <
typename T>
372 ReturnType *returnType =
nullptr);
378 template <
typename T>
382 std::chrono::seconds expiration,
383 ReturnType *returnType =
nullptr);
403 ReturnType *returnType =
nullptr);
411 std::chrono::seconds expiration,
412 ReturnType *returnType =
nullptr);
432 template <
typename T>
436 ReturnType *returnType =
nullptr);
442 template <
typename T>
445 std::chrono::seconds expiration,
446 ReturnType *returnType =
nullptr);
471 ReturnType *returnType =
nullptr);
480 std::chrono::seconds expiration,
481 ReturnType *returnType =
nullptr);
504 template <
typename T>
509 ReturnType *returnType =
nullptr);
515 template <
typename T>
519 std::chrono::seconds expiration,
520 ReturnType *returnType =
nullptr);
540 ReturnType *returnType =
nullptr);
548 std::chrono::seconds expiration,
549 ReturnType *returnType =
nullptr);
568 template <
typename T>
572 ReturnType *returnType =
nullptr);
578 template <
typename T>
581 std::chrono::seconds expiration,
582 ReturnType *returnType =
nullptr);
607 ReturnType *returnType =
nullptr);
616 std::chrono::seconds expiration,
617 ReturnType *returnType =
nullptr);
640 template <
typename T>
645 ReturnType *returnType =
nullptr);
651 template <
typename T>
655 std::chrono::seconds expiration,
656 ReturnType *returnType =
nullptr);
676 get(
QByteArrayView key, uint64_t *cas =
nullptr, ReturnType *returnType =
nullptr);
708 template <
typename T>
709 static T get(
QByteArrayView key, uint64_t *cas =
nullptr, ReturnType *returnType =
nullptr);
733 uint64_t *cas =
nullptr,
734 ReturnType *returnType =
nullptr);
771 template <
typename T>
774 uint64_t *cas =
nullptr,
775 ReturnType *returnType =
nullptr);
785 static bool remove(
QByteArrayView key, ReturnType *returnType =
nullptr);
809 static bool exist(
QByteArrayView key, ReturnType *returnType =
nullptr);
830 static const time_t expirationNotAdd;
839 static const std::chrono::seconds expirationNotAddDuration;
858 uint64_t *value =
nullptr,
859 ReturnType *returnType =
nullptr);
882 uint64_t *value =
nullptr,
883 ReturnType *returnType =
nullptr);
913 uint64_t *value =
nullptr,
914 ReturnType *returnType =
nullptr);
923 std::chrono::seconds expiration,
924 uint64_t *value =
nullptr,
925 ReturnType *returnType =
nullptr);
961 uint64_t *value =
nullptr,
962 ReturnType *returnType =
nullptr);
968 inline static bool incrementWithInitialByKey(
QByteArrayView groupKey,
972 std::chrono::seconds expiration,
973 uint64_t *value =
nullptr,
974 ReturnType *returnType =
nullptr);
993 uint64_t *value =
nullptr,
994 ReturnType *returnType =
nullptr);
1017 uint64_t *value =
nullptr,
1018 ReturnType *returnType =
nullptr);
1048 uint64_t *value =
nullptr,
1049 ReturnType *returnType =
nullptr);
1058 std::chrono::seconds expiration,
1059 uint64_t *value =
nullptr,
1060 ReturnType *returnType =
nullptr);
1096 uint64_t *value =
nullptr,
1097 ReturnType *returnType =
nullptr);
1103 inline static bool decrementWithInitialByKey(
QByteArrayView groupKey,
1107 std::chrono::seconds expiration,
1108 uint64_t *value =
nullptr,
1109 ReturnType *returnType =
nullptr);
1127 ReturnType *returnType =
nullptr);
1135 std::chrono::seconds expiration,
1137 ReturnType *returnType =
nullptr);
1153 template <
typename T>
1158 ReturnType *returnType =
nullptr);
1164 template <
typename T>
1167 std::chrono::seconds expiration,
1169 ReturnType *returnType =
nullptr);
1194 ReturnType *returnType =
nullptr);
1203 std::chrono::seconds expiration,
1205 ReturnType *returnType =
nullptr);
1227 template <
typename T>
1233 ReturnType *returnType =
nullptr);
1239 template <
typename T>
1243 std::chrono::seconds expiration,
1245 ReturnType *returnType =
nullptr);
1255 static bool flushBuffers(ReturnType *returnType =
nullptr);
1268 static bool flush(time_t expiration, ReturnType *returnType =
nullptr);
1274 inline static bool flush(std::chrono::seconds expiration, ReturnType *returnType =
nullptr);
1291 ReturnType *returnType =
nullptr);
1308 template <
typename T>
1311 ReturnType *returnType =
nullptr);
1335 ReturnType *returnType =
nullptr);
1358 template <
typename T>
1362 ReturnType *returnType =
nullptr);
1373 static bool touch(
QByteArrayView key, time_t expiration, ReturnType *returnType =
nullptr);
1380 std::chrono::seconds expiration,
1381 ReturnType *returnType =
nullptr);
1400 ReturnType *returnType =
nullptr);
1408 std::chrono::seconds expiration,
1409 ReturnType *returnType =
nullptr);
1428 const std::unique_ptr<MemcachedPrivate> d_ptr;
1433 std::chrono::seconds expiration,
1434 ReturnType *returnType)
1436 return Memcached::set(key, value, expiration.count(), returnType);
1439 template <
typename T>
1440 bool Memcached::set(
QByteArrayView key,
const T &value, time_t expiration, ReturnType *returnType)
1445 return Memcached::set(key, data, expiration, returnType);
1448 template <
typename T>
1451 std::chrono::seconds expiration,
1452 ReturnType *returnType)
1454 return Memcached::set<T>(key, value, expiration.count(), returnType);
1460 std::chrono::seconds expiration,
1461 ReturnType *returnType)
1463 return Memcached::setByKey(groupKey, key, value, expiration.count(), returnType);
1466 template <
typename T>
1471 ReturnType *returnType)
1476 return Memcached::setByKey(groupKey, key, data, expiration, returnType);
1479 template <
typename T>
1483 std::chrono::seconds expiration,
1484 ReturnType *returnType)
1486 return Memcached::setByKey<T>(groupKey, key, value, expiration.count(), returnType);
1491 std::chrono::seconds expiration,
1492 ReturnType *returnType)
1494 return Memcached::add(key, value, expiration.count(), returnType);
1497 template <
typename T>
1498 bool Memcached::add(
QByteArrayView key,
const T &value, time_t expiration, ReturnType *returnType)
1503 return Memcached::add(key, data, expiration, returnType);
1506 template <
typename T>
1509 std::chrono::seconds expiration,
1510 ReturnType *returnType)
1512 return Memcached::add<T>(key, value, expiration.count(), returnType);
1518 std::chrono::seconds expiration,
1519 ReturnType *returnType)
1521 return Memcached::addByKey(groupKey, key, value, expiration.count(), returnType);
1524 template <
typename T>
1529 ReturnType *returnType)
1534 return Memcached::addByKey(groupKey, key, data, expiration, returnType);
1537 template <
typename T>
1541 std::chrono::seconds expiration,
1542 ReturnType *returnType)
1544 return Memcached::addByKey<T>(groupKey, key, value, expiration.count(), returnType);
1549 std::chrono::seconds expiration,
1550 ReturnType *returnType)
1552 return Memcached::replace(key, value, expiration.count(), returnType);
1555 template <
typename T>
1559 ReturnType *returnType)
1564 return Memcached::replace(key, data, expiration, returnType);
1567 template <
typename T>
1570 std::chrono::seconds expiration,
1571 ReturnType *returnType)
1573 return Memcached::replace<T>(key, value, expiration.count(), returnType);
1579 std::chrono::seconds expiration,
1580 ReturnType *returnType)
1582 return Memcached::replaceByKey(groupKey, key, value, expiration.count(), returnType);
1585 template <
typename T>
1590 ReturnType *returnType)
1595 return Memcached::replaceByKey(groupKey, key, data, expiration, returnType);
1598 template <
typename T>
1602 std::chrono::seconds expiration,
1603 ReturnType *returnType)
1605 return Memcached::replaceByKey<T>(groupKey, key, value, expiration.count(), returnType);
1611 std::chrono::seconds expiration,
1613 ReturnType *returnType)
1615 return Memcached::incrementWithInitial(
1616 key, offset, initial, expiration.count(), value, returnType);
1619 inline bool Memcached::incrementWithInitialByKey(
QByteArrayView groupKey,
1623 std::chrono::seconds expiration,
1625 ReturnType *returnType)
1627 return Memcached::incrementWithInitialByKey(
1628 groupKey, key, offset, initial, expiration.count(), value, returnType);
1634 std::chrono::seconds expiration,
1636 ReturnType *returnType)
1638 return Memcached::decrementWithInitial(
1639 key, offset, initial, expiration.count(), value, returnType);
1642 inline bool Memcached::decrementWithInitialByKey(
QByteArrayView groupKey,
1646 std::chrono::seconds expiration,
1648 ReturnType *returnType)
1650 return Memcached::decrementWithInitialByKey(
1651 groupKey, key, offset, initial, expiration.count(), value, returnType);
1654 template <
typename T>
1655 T Memcached::get(
QByteArrayView key, uint64_t *cas, ReturnType *returnType)
1658 QByteArray ba = Memcached::get(key, cas, returnType);
1666 template <
typename T>
1670 ReturnType *returnType)
1673 QByteArray ba = Memcached::getByKey(groupKey, key, cas, returnType);
1683 std::chrono::seconds expiration,
1685 ReturnType *returnType)
1687 return Memcached::cas(key, value, expiration.count(), cas, returnType);
1690 template <
typename T>
1695 ReturnType *returnType)
1700 return Memcached::cas(key, data, expiration, cas, returnType);
1703 template <
typename T>
1706 std::chrono::seconds expiration,
1708 ReturnType *returnType)
1710 return Memcached::cas<T>(key, value, expiration.count(), cas, returnType);
1716 std::chrono::seconds expiration,
1718 ReturnType *returnType)
1720 return Memcached::casByKey(groupKey, key, value, expiration.count(), cas, returnType);
1723 template <
typename T>
1729 ReturnType *returnType)
1734 return Memcached::casByKey(groupKey, key, data, expiration, cas, returnType);
1737 template <
typename T>
1741 std::chrono::seconds expiration,
1743 ReturnType *returnType)
1745 return Memcached::casByKey<T>(groupKey, key, value, expiration.count(), cas, returnType);
1748 inline bool Memcached::flush(std::chrono::seconds expiration, ReturnType *returnType)
1750 return Memcached::flush(expiration.count(), returnType);
1753 template <
typename T>
1756 ReturnType *returnType)
1760 if (!_data.
empty()) {
1766 hash.
insert(i.key(), retVal);
1773 template <
typename T>
1777 ReturnType *returnType)
1781 Memcached::mgetByKey(groupKey, keys, casValues, returnType);
1782 if (!_data.
empty()) {
1788 hash.
insert(i.key(), retVal);
1796 Memcached::touch(
QByteArrayView key, std::chrono::seconds expiration, ReturnType *returnType)
1798 return Memcached::touch(key, expiration.count(), returnType);
1803 std::chrono::seconds expiration,
1804 ReturnType *returnType)
1806 return Memcached::touchByKey(groupKey, key, expiration.count(), returnType);
The Cutelyst application.
Cutelyst Memcached plugin.
Base class for Cutelyst Plugins.
The Cutelyst namespace holds all public Cutelyst API.
bool isEmpty() const const
QHash::const_iterator constBegin() const const
QHash::const_iterator constEnd() const const
QHash::iterator insert(const Key &key, const T &value)