1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-15 17:51:06 +00:00
dragonflydb-dragonfly/server/table.h
Roman Gershman d64b4e01ea Implement basic list operations
Fix redis linker dependencies. Bring more redis (BSD-3) code.
Fix bugs related to multi-database redis.
Introduce multiple types for redis values.
2022-01-02 10:40:16 +02:00

44 lines
950 B
C++

// Copyright 2021, Roman Gershman. All rights reserved.
// See LICENSE for licensing terms.
//
#pragma once
#include <absl/container/flat_hash_map.h>
namespace dfly {
struct MainValue {
std::string str;
void* robj = nullptr;
uint8_t obj_type = 0;
MainValue() = default;
MainValue(std::string_view s) : str(s) {
}
bool HasExpire() const {
return has_expire_;
}
void SetExpire(bool b) {
has_expire_ = b;
}
unsigned ObjType() const {
return obj_type;
}
private:
bool has_expire_ = false;
};
using MainTable = absl::flat_hash_map<std::string, MainValue>;
using ExpireTable = absl::flat_hash_map<std::string, uint64_t>;
/// Iterators are invalidated when new keys are added to the table or some entries are deleted.
/// Iterators are still valid if a different entry in the table was mutated.
using MainIterator = MainTable::iterator;
using ExpireIterator = ExpireTable::iterator;
} // namespace dfly