TreeFrogFramework: src/tsharedmemorykvs.h Source File

1#pragma once

2#include <QByteArray>

3#include <QStringList>

4#include <TGlobal>

5#include <TKvsDatabase>

6#include <TfNamespace>

7

8struct hash_header_t;

9class TSharedMemoryKvsDriver;

10

11

13public:

15 public:

18 qint64 expires {0};

19

24

26 {

27 key.resize(0);

28 value.resize(0);

29 expires = 0;

30 }

31

37

43 };

44

46 public:

48 const QByteArray &key() const;

49 const QByteArray &value() const;

50 bool isExpired() const;

51 const QByteArray &operator*() const;

55 void remove();

56 private:

58 void search();

59

61 uint _it {0};

62 bool _locked {false};

63 Bucket _tmpbk;

65 };

66

69

70 QByteArray get(const QByteArray &key);

71 bool set(const QByteArray &key, const QByteArray &value, int seconds);

72 bool remove(const QByteArray &key);

73 uint count() const;

74 uint tableSize() const;

75 void clear();

76 void gc();

77 float loadFactor() const;

78 void rehash();

79 bool lockForRead();

80 bool lockForWrite();

81 bool unlock();

82

85

86 static bool initialize(const QString &name, const QString &options);

87 void cleanup();

88

89protected:

90 uint find(const QByteArray &key, Bucket &bucket) const;

91 bool find(uint index, Bucket &bucket) const;

93 uint index(const QByteArray &key) const;

94 uint next(uint index) const;

95 void remove(uint index);

96

97

98private:

100 TSharedMemoryKvsDriver *driver();

101 const TSharedMemoryKvsDriver *driver() const;

102

103 TKvsDatabase _database;

104 hash_header_t *_h {nullptr};

105

106 friend class TCacheSharedMemoryStore;

109};

KvsEngine

Definition tfnamespace.h:239

T_CORE_EXPORT int64_t getMSecsSinceEpoch()

Definition tglobal.cpp:295

#define T_CORE_EXPORT

Definition tdeclexport.h:28

#define T_DISABLE_COPY(Class)

Definition tdeclexport.h:37

#define T_DISABLE_MOVE(Class)

Definition tdeclexport.h:41