Re: [Cppcms-users] Using cache in application constructor
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2015-11-23 11:09:42
|
> Hi! > > We can use cache only if context exists. But in application constructor - > context is not exists yet. So what we should to do, if we caching database > requests and we need to load some data in application constructor? (well, cache > designed for responses mostly, but it can be used internally as well - instead > of external solutions). > Good question.. In CppCMS 1.0.x I suggest to access cache on first request, i.e. to put in main - if something is not cached load it otherwise use it. In CpppCMS 1.1.0 - in trunk you can create a cache_interface object independently from service - for cases when you need cache outside request/response context. You obviously can't cache response output this way but it does not really matter :-) Currently development on CppCMS 1.1.x i.e. beta of 1.2.0 is under very active development and I hope to keep it this way until 1.2 is released. Also note currently trunk is little unstable due to some refactoring of the internal code - due to implementation of non-blocking interface for asynchronous applications. Also all the (important) tests now running fine still there may be some issues. http://cppcms.com/files/nightly-build-report.html > 3. Don't caching database requests at all. > Most databases have own caching mechanisms, but we better know the logic of our > application and also can use own small storage solutions (well, may be they > should use own cache too). > It is always more efficient to cache final result (for example rendered HTML page) rather then database for two reasons: (a) output is cached in already gzipped mode (b) You already have done all processing. Of course it isn't possible in many cases. Caching DB is very good for "long living" data that is complex to retrieve and not updated frequently. > > Thanks! > > Regards, > kpeo > Regards, Artyom |