Now RCPPFramework can also allocate the FileCache singleotn.

This commit is contained in:
Relintai 2022-02-05 18:39:27 +01:00
parent ffbdae1520
commit b2503ba587
2 changed files with 18 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#endif #endif
#if WEB_ENABLED #if WEB_ENABLED
#include "web/file_cache.h"
#include "web/http/session_manager.h" #include "web/http/session_manager.h"
#endif #endif
@ -76,6 +77,7 @@ RCPPFramework::RCPPFramework() {
#if WEB_ENABLED #if WEB_ENABLED
allocate_session_manager_singleton = true; allocate_session_manager_singleton = true;
allocate_file_cache_singleton = true;
#endif #endif
} }
@ -115,7 +117,17 @@ void RCPPFramework::_do_initialize() {
#if WEB_ENABLED #if WEB_ENABLED
if (allocate_session_manager_singleton) { if (allocate_session_manager_singleton) {
::SessionManager *session_manager = new ::SessionManager(); ::SessionManager *session_manager = new ::SessionManager();
RCPPFramework::get_singleton()->manage_object(session_manager); manage_object(session_manager);
}
if (allocate_file_cache_singleton) {
FileCache *file_cache = new FileCache(true);
manage_object(file_cache);
if (www_root != "") {
file_cache->wwwroot = www_root;
file_cache->wwwroot_refresh_cache();
}
} }
#endif #endif
} }

View File

@ -36,6 +36,11 @@ public:
#if WEB_ENABLED #if WEB_ENABLED
bool allocate_session_manager_singleton; bool allocate_session_manager_singleton;
bool allocate_file_cache_singleton;
// By default it's set to "".
// It will be ignored if you leave it.
String www_root;
#endif #endif
protected: protected: