5 #include <TKvsDatabase>
9 class TSharedMemoryKvsDriver;
48 const QByteArray &key()
const;
49 const QByteArray &value()
const;
50 bool isExpired()
const;
51 const QByteArray &operator*()
const;
70 QByteArray
get(
const QByteArray &key);
71 bool set(
const QByteArray &key,
const QByteArray &value,
int seconds);
72 bool remove(
const QByteArray &key);
86 static bool initialize(
const QString &name,
const QString &options);
90 uint
find(
const QByteArray &key,
Bucket &bucket)
const;
93 uint
index(
const QByteArray &key)
const;
100 TSharedMemoryKvsDriver *driver();
101 const TSharedMemoryKvsDriver *driver()
const;
103 TKvsDatabase _database;
104 hash_header_t *_h {
nullptr};
106 friend class TCacheSharedMemoryStore;
The Bucket class represents a data bucket for the in-memory KVS.
Definition: tsharedmemorykvs.h:14
QByteArray value
Definition: tsharedmemorykvs.h:17
qint64 expires
Definition: tsharedmemorykvs.h:18
friend QDataStream & operator>>(QDataStream &ds, Bucket &bucket)
Definition: tsharedmemorykvs.h:38
bool isExpired() const
Definition: tsharedmemorykvs.h:20
friend QDataStream & operator<<(QDataStream &ds, const Bucket &bucket)
Definition: tsharedmemorykvs.h:32
void clear()
Definition: tsharedmemorykvs.h:25
QByteArray key
Definition: tsharedmemorykvs.h:16
The WriteLockingIterator class provides an STL-style iterator with write-locking for TSharedMemoryKvs...
Definition: tsharedmemorykvs.h:45
bool operator==(const WriteLockingIterator &other) const
Definition: tsharedmemorykvs.h:53
bool operator!=(const WriteLockingIterator &other) const
Definition: tsharedmemorykvs.h:54
The TSharedMemoryKvs class provides a means of operating a in-memory KVS built in the server process.
Definition: tsharedmemorykvs.h:12
uint index(const QByteArray &key) const
Definition: tsharedmemorykvs.cpp:399
void gc()
Executes garbage collection.
Definition: tsharedmemorykvs.cpp:331
float loadFactor() const
Definition: tsharedmemorykvs.cpp:302
void cleanup()
Cleanup the KVS.
Definition: tsharedmemorykvs.cpp:105
uint next(uint index) const
Definition: tsharedmemorykvs.cpp:405
static bool initialize(const QString &name, const QString &options)
Initializes in-memory KVS with the given name and options.
Definition: tsharedmemorykvs.cpp:84
WriteLockingIterator end()
Returns an STL-style iterator pointing just after the last item in the KVS.
Definition: tsharedmemorykvs.cpp:490
int searchIndex(int first)
uint find(const QByteArray &key, Bucket &bucket) const
Definition: tsharedmemorykvs.cpp:185
~TSharedMemoryKvs()
Destructor.
Definition: tsharedmemorykvs.cpp:78
QByteArray get(const QByteArray &key)
Returns the value associated with the key; otherwise returns an empty byte array.
Definition: tsharedmemorykvs.cpp:250
bool remove(const QByteArray &key)
Removes the specified key.
Definition: tsharedmemorykvs.cpp:263
WriteLockingIterator begin()
Locks the attached shared-memory segment for writing by this process and returns an STL-style iterato...
Definition: tsharedmemorykvs.cpp:479
TSharedMemoryKvs()
Constructs a TSharedMemoryKvs object.
Definition: tsharedmemorykvs.cpp:62
bool set(const QByteArray &key, const QByteArray &value, int seconds)
Sets the key to hold the value.
Definition: tsharedmemorykvs.cpp:114
bool lockForWrite()
Locks the shared memory segment for writing by this process.
Definition: tsharedmemorykvs.cpp:421
void rehash()
Internal use.
Definition: tsharedmemorykvs.cpp:347
bool lockForRead()
Locks the shared memory segment for reading by this process.
Definition: tsharedmemorykvs.cpp:413
void clear()
Removes all items from the KVS.
Definition: tsharedmemorykvs.cpp:310
uint tableSize() const
Definition: tsharedmemorykvs.cpp:296
bool unlock()
Releases the lock on the shared memory segment.
Definition: tsharedmemorykvs.cpp:429
uint count() const
Returns the number of items set.
Definition: tsharedmemorykvs.cpp:290
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