Filecache question
My first question isn't about filecache but dirtycache. Although it is more of a complain than a real question...
I've checked that cache is enabled with Gdn::Cache()->ActiveEnabled() and tried using the cache with Gdn::Cache()->Get() and Gdn::Cache()->Store() and was about to open a thread asking for help why it doen't work.
Before asking a question, I try searching the forum and found that: http://vanillaforums.org/discussion/comment/153981#Comment_153981
x00 said:
Dirty cache doesn't do anything.
So why on earth does Gdn::Cache()->ActiveEnabled() is TRUE when the activate cache is no cache?! Is that a bug? Well you can not call that a bug, because it is obviously on purpose, but simply rubbish to my opinion. Is there any reason for that?
But away with that...
I switched from dirtycache to filecache now, but I'm not happy. The same discussion above showed that there might be an issue with the $Configuration['Cache']['Filecache']['Store'] = PATH_LOCAL_CACHE.'/Filecache';
setting, not stating what the error will look like. Besides of that, there isn't much to find for filecache. It seems to have not worked 2012 in 2.0.18.4
http://vanillaforums.org/discussion/22213/caching-strategies-for-vanilla-2-0-18-4
The error message I get is "Cannot create references to/from string offsets nor overloaded objects in /library/core/class.thememanager.php on line 87" and when I search for that I get http://vanillaforums.org/discussion/18053/fatal-error-cannot-create-references-to-from-string-offsets-nor-overloaded-objects from 2011. Removing the "&" is no solution: afterwards it is impossible to login and I think permissions are going amok. I can not see any discussion and if I try to open one I know the url of, I am redirected to login screen. Logging in as admin tells me my password is wrong, logging in as user tells me I have no permission. I suspect permissions are cached and if cache is corrupt, checking permissions doesn't lead to reasonable results.
Someone opened up that filecache issue on GitHub long, long, long time ago: https://github.com/vanillaforums/Garden/issues/1005 but that issue was closed by @Todd 7 month ago.
So was filecache never completely integrated into Vanilla or is there a trick that I haven't found by now?
Answers
file cache is not worth it IMO, database does its write and reads in a more efficient way you are basically using up resource most people don't have.
By design it is actually fairly elegant, in the sense that the architecture considers caching, and serves as a stub for future limited per request caching, which is implemented in 2.1
grep is your friend.
If Garden has a cache stub which just simulates a cache so that it can be implemented later, it should at least step away from using such constructs:
if (Gdn::Cache()->ActiveEnabled())
...It pretends the framework has a feature that it has in fact not. And it is far from being obvious why Gdn::Cache()->Store('MyKey', 'MyValue'), Gdn::Cache()->Get('MyKey) doesn't work.
When I look at Gardens config file I see three bad config lines:
If dirtycache is no cache and enabled by default, option Enabled is redundant and irritating.
Filecache.Store belongs to a not broken feature, that might have never worked. And that also might be inefficient.
Method is the only thing that makes sense, but some name like a clear and honest none would be far better.
For what it worth, file cache is the most common cause for many people that use sharing hosting to have their account suspended when they enable file cache for their site. It is also a source of a vector for abuse and attack. I would stay away from any form of file cache! It cause more ahead then it help.
Database cache might be a different story. It is more efficient and faster.
There are common situations where file caching is the best choice. Static page caching is useful for sites that do not have a lot of dynamic content which are meant evaluated often by PHP. In such cases, the static page cache can be loaded directly from the web server; thus, bypassing PHP entirely and increasing the amount of requests per second.
Vanilla currently does not make use of the file cache for this purpose due to the dynamic nature of the content. The caching methods for Vanilla have been improved a bit since 2.1 with more options for opcode caching with APC and Memcached for distributed memory caching purposes.
Add Pages to Vanilla with the Basic Pages app
these cache options are not available on most share hosting unless you have your own VPS or dedicated server then you can cache all you want.
@Shadowdare: there are several things that are cached in Vanilla: config settings and db queries. Replacing the config access by a filecache would be obviously useless.
Whether file caching db queries is useful or not depends and you couldn't know until you've tried. At least that seems to be the most widespread opinion as I conclude from my searches. I'd like to try if filecaching would be useful but I could not :-(
For sure it is the best to cache data in memory but that's not an option if you are using a webhosting service, as chanh already stated.
If the file cache is set to to /dev/shm it goes into memory.