ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
954 B

  1. #define CPPCMS_SOURCE
  2. #include "cache_pool.h"
  3. #include "thread_cache.h"
  4. #include "base_cache.h"
  5. #include "cppcms_error.h"
  6. #include "json.h"
  7. namespace cppcms {
  8. struct cache_pool::data {
  9. intrusive_ptr<impl::base_cache> module;
  10. };
  11. cache_pool::cache_pool(json::value const &settings) :
  12. d(new data())
  13. {
  14. std::string type = settings.get("cache.backend","none");
  15. if(type == "none" )
  16. return;
  17. if(type=="thread_shared") {
  18. if(settings.get("service.worker_processes",0)>1)
  19. throw cppcms_error(
  20. "Can't use `thread_shared' backend with more then one process ether set "
  21. "service.worker_processes to 0 or 1 or use cache.backend=\"process_shared\"");
  22. unsigned items = settings.get("cache.limit",64);
  23. d->module=impl::thread_cache_factory(items);
  24. }
  25. else {
  26. throw cppcms_error("Unsupported cache backend `" + type + "'");
  27. }
  28. }
  29. cache_pool::~cache_pool()
  30. {
  31. }
  32. intrusive_ptr<impl::base_cache> cache_pool::get()
  33. {
  34. return d->module;
  35. }
  36. } // cppcms