1
0
Fork 0
forked from blue/lmdbal

some debug, some idea how to utilize home hints of data by cache

This commit is contained in:
Blue 2022-10-08 19:45:07 +03:00
parent a613eaed27
commit c23dae2a25
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
2 changed files with 91 additions and 21 deletions

18
cache.h
View file

@ -25,27 +25,31 @@
template <class K, class V>
class DataBase::Cache : public DataBase::Table<K, V> {
friend class DataBase;
enum class Mode {
nothing,
size,
full
enum class Mode { //it's a cache state when we:
nothing, // - know nothing about records in database on disk
size, // - know just an amount of records
full // - shure that our cache is equal to the database on disk
};
protected:
Cache(const std::string& name, DataBase* parent);
~Cache() override;
private:
void handleMode() const;
public:
virtual void addRecord(const K& key, const V& value) override;
virtual void changeRecord(const K& key, const V& value) override;
virtual void removeRecord(const K& key) override;
virtual V getRecord(const K& key) const override;
//virtual uint32_t count() const;
//virtual void drop();
virtual uint32_t count() const override;
virtual void drop() override;
protected:
Mode mode;
Mode* mode;
std::map<K, V>* cache;
std::set<K>* abscent;
uint32_t* sizeDifference;
};
#include "cache.hpp"