FDL Core Library
ASC Framing Decision List — C/C++ Reference Implementation
Loading...
Searching...
No Matches
fdl_tl_cache.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024-present American Society Of Cinematographers
2// SPDX-License-Identifier: Apache-2.0
17#ifndef FDL_TL_CACHE_H
18#define FDL_TL_CACHE_H
19
20#include <string>
21#include <unordered_map>
22
23#include "fdl_constants.h"
24
25namespace fdl::detail {
26
36template<typename Key, typename Hash> class TlStringCache {
37public:
48 std::string& get(const Key& key) {
49 if (map_.size() >= fdl::constants::kTlCacheMaxEntries) {
50 map_.clear();
51 }
52 return map_[key];
53 }
54
55private:
56 std::unordered_map<Key, std::string, Hash> map_;
57};
58
59} // namespace fdl::detail
60
61#endif // FDL_TL_CACHE_H
Bounded thread-local string cache with auto-eviction.
Definition fdl_tl_cache.h:36
std::string & get(const Key &key)
Get or create a cached string entry for the given key.
Definition fdl_tl_cache.h:48
Named constants replacing magic numbers throughout the FDL core library.