forked from blue/lmdbal
some debug, some idea how to utilize home hints of data by cache
This commit is contained in:
parent
a613eaed27
commit
c23dae2a25
2 changed files with 91 additions and 21 deletions
18
cache.h
18
cache.h
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue