From b2503ba587df12890a457d650507125b5dd870d3 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 5 Feb 2022 18:39:27 +0100 Subject: [PATCH] Now RCPPFramework can also allocate the FileCache singleotn. --- rcpp_framework.cpp | 14 +++++++++++++- rcpp_framework.h | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/rcpp_framework.cpp b/rcpp_framework.cpp index 3085037..095f037 100644 --- a/rcpp_framework.cpp +++ b/rcpp_framework.cpp @@ -8,6 +8,7 @@ #endif #if WEB_ENABLED +#include "web/file_cache.h" #include "web/http/session_manager.h" #endif @@ -76,6 +77,7 @@ RCPPFramework::RCPPFramework() { #if WEB_ENABLED allocate_session_manager_singleton = true; + allocate_file_cache_singleton = true; #endif } @@ -115,7 +117,17 @@ void RCPPFramework::_do_initialize() { #if WEB_ENABLED if (allocate_session_manager_singleton) { ::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 } diff --git a/rcpp_framework.h b/rcpp_framework.h index 0347629..557ffa8 100644 --- a/rcpp_framework.h +++ b/rcpp_framework.h @@ -36,6 +36,11 @@ public: #if WEB_ENABLED 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 protected: