mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Added clear method to FileCache.
This commit is contained in:
parent
60ed46b5e6
commit
60e7dfe7e9
@ -101,6 +101,24 @@ void FileCache::set_cached_body(const String &path, const String &body) {
|
||||
cache_mutex.unlock();
|
||||
}
|
||||
|
||||
void FileCache::clear() {
|
||||
cache_mutex.lock();
|
||||
|
||||
registered_files.clear();
|
||||
|
||||
for (std::map<String, CacheEntry *>::iterator E = cache_map.begin(); E != cache_map.end(); E++) {
|
||||
CacheEntry * ce = E->second;
|
||||
|
||||
if (ce) {
|
||||
delete ce;
|
||||
}
|
||||
}
|
||||
|
||||
cache_map.clear();
|
||||
|
||||
cache_mutex.unlock();
|
||||
}
|
||||
|
||||
FileCache::FileCache(bool singleton) {
|
||||
if (singleton) {
|
||||
if (_instance) {
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
bool get_cached_body(const String &path, String *body);
|
||||
void set_cached_body(const String &path, const String &body);
|
||||
|
||||
void clear();
|
||||
|
||||
FileCache(bool singleton = false);
|
||||
virtual ~FileCache();
|
||||
|
||||
@ -43,7 +45,6 @@ protected:
|
||||
};
|
||||
|
||||
std::mutex cache_mutex;
|
||||
|
||||
std::map<String, CacheEntry *> cache_map;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user