Class DentryCache
Defined in File cache.hpp
Class Documentation
-
class DentryCache
Cache for directory entries to accelerate ls -l type operations.
Public Functions
-
DentryCache() = default
-
virtual ~DentryCache() = default
-
void insert(const std::string &parent_dir, std::string name, cache_entry value)
Insert a new entry in the cache.
- Parameters:
parent_dir –
name –
value –
-
std::optional<cache_entry> get(const std::string &parent_dir, const std::string &name)
Get an entry from the cache for a given directory.
- Parameters:
parent_dir –
name –
- Returns:
std::optional<cache_entry>
-
void clear_dir(const std::string &dir_path)
Clear the cache for a given directory. Called when a directory is closed.
- Parameters:
dir_path –
-
void dump_cache_to_log(const std::string &dir_path)
Dump the cache to the log for debugging purposes. Not used in production.
- Parameters:
dir_path –
-
void clear()
Clear the entire cache.
Private Functions
-
uint32_t gen_dir_id(const std::string &dir_path)
Generate a unique id for caching a directory.
- Parameters:
dir_path –
- Returns:
id
-
uint32_t get_dir_id(const std::string &dir_path)
Get the unique id for a directory to retrieve its entries. Creates an id if it does not exist.
- Parameters:
dir_path –
- Returns:
id
Private Members
-
std::unordered_map<uint32_t, std::unordered_map<std::string, cache_entry>> entries_
-
std::unordered_map<std::string, uint32_t> entry_dir_id_
-
std::mutex mtx_
-
std::hash<std::string> str_hash
-
DentryCache() = default