diff --git a/core/file_cache.cpp b/core/file_cache.cpp index 91102eb..14c0b66 100644 --- a/core/file_cache.cpp +++ b/core/file_cache.cpp @@ -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::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) { diff --git a/core/file_cache.h b/core/file_cache.h index 56b8738..f06ebc7 100644 --- a/core/file_cache.h +++ b/core/file_cache.h @@ -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 cache_map; private: