README.txt contains the following passage:
In Drupal 7+, you no longer should set cache_inc in settings.php. Instead, you
will have to manually include 'cache.inc' and 'memcache.inc', then update $conf
to tell Drupal to default to memcache for caching:
In fact, there is a way to specify memcache cache handler in settings.php, using $conf['cache_backends'] variable, like this:
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
I think this way is preferred. See includes/bootstrap.inc, lines 2147-2152 (D7 RC4):
// Allow specifying special cache handlers in settings.php, like
// using memcached or files for storing cache information.
require_once DRUPAL_ROOT . '/includes/cache.inc';
foreach (variable_get('cache_backends', array()) as $include) {
require_once DRUPAL_ROOT . '/' . $include;
}
Comments
Comment #1
jeremy commentedWhen I change my configuration of settings.php as you have recommended, memcache ceases to work.
Comment #2
jeremy commentedAh, what does seem to work is the following two lines together:
That makes sense to me, agreed?
Comment #3
valthebaldDeal :)
Comment #4
danepowell commentedI can confirm that #2 gets the job done. By the way, the project page should be updated to reflect this information- the current instructions there don't work for Drupal 7. Or, it might be better to trim down the project page and just provide links to the latest README / INSTALLATION files for each version of memcache.
Comment #5
pillarsdotnet commentedSo which of the following lines from my
settings.phpshould be removed? Or are they all needed?Comment #6
hawksjohnd commented#2 worked for me, if these generally work I suggest updating the INSTALLATION.txt and README.txt accordingly to note that those lines will work for many installations.
I tried every variation on the stock include lines resulting in WSOD every time. I was really happy to find this thread, it's the only place I've run into these instructions!
Comment #7
jeremy commentedI've committed a cleanup to README.txt:
http://drupalcode.org/project/memcache.git/commit/7e30817
Comment #8
pillarsdotnet commentedCan I get an answer to #5 or should I copy it to a separate support request?
Comment #9
jeremy commented@pillarsdotnet: Try replacing it ALL with just these two lines:
That will give you basic Memcache functionality, and you can expand it from there as necessary.
Comment #10
pillarsdotnet commentedHave you read the following issue? #512026: Move $form_state storage from cache to new state/key-value system
I believe at least the following is also needed:
Comment #11
pillarsdotnet commentedPatch to correct the above deficiency as well as other miscellaneous typos in the README.txt file.
Comment #12
jeremy commentedLooks good -- I committed this cleanup, and added the additional conf line to the inline examples later in the README as well:
http://drupalcode.org/project/memcache.git/commit/bb2165f
Comment #14
byrond commentedSorry if I'm misunderstanding something, but should the workaround for issue #512026 be the following?
Comment #15
pillarsdotnet commented@byrond
Yup. As is now mentioned in the
README.txtfile:Comment #16
byrond commentedSo, there's no difference between 'cache_class_form' and 'cache_class_cache_form'?
Comment #17
pillarsdotnet commentedSorry; the version in the README is correct; the other one is not, unless you have somehow modified Drupal core. I've been confused by that myself, more than once.
Comment #18
byrond commentedWell, I'm really confused then. I haven't modified core (don't care much for kittens, but I still can't quite cross that line), but I did take a look around. The _cache_get_object function appends the $bin parameter to 'cache_class_' to determine the name of the variable that holds the cache class name.
This is what it said about the $bin parameter:
...which means for 'cache_form', the _cache_get_object function is going to be looking for a variable named 'cache_class_cache_form'. I also looked at form.inc, and there are statements that call cache_get and cache_set with an argument of 'cache_form'. Issue #512026 seems to be talking about the bin named 'cache_form' and possibly renaming it to 'form_state', but to my knowledge that hasn't happened yet.
If I'm way off here, could someone point me to some documentation to the possible cache bins and how to define classes for them? Everything I have seen to this point states you should use a 'cache_class_' prefix and the bin name ('cache_menu', 'cache_page', and I assume 'cache_form').
Comment #19
byrond commentedReopening, as it seems other documentation instructs to use 'cache_class_cache_form' and not 'cache_class_form'...
http://drupal.org/node/797346
http://drupal.org/node/1099596#comment-4469062
Also, we are using 'cache_class_cache_form', and we get the expected behavior (memcache is not handling 'cache_form').
Comment #20
pillarsdotnet commentedOkay, I'm gonna press the "I believe" button and roll a patch (even though I don't currently use Memcache anymore) just so I can set this to "needs review" where the maintainers will actually see it.
Comment #21
pillarsdotnet commentedComment #22
jlporter commentedBumpety bump...
I only changed my config as described in #2 and it's working now(with elasticache!).
Comment #23
pillarsdotnet commented@jlporter: Presumably you mean #20?
Mark this RTBC if you feel the change is correct.
Comment #24
berdirChange looks good to me.
Comment #25
catchCommitted and pushed, thanks!
Comment #26
Prague man commentedI apply the patch and than:
Fatal error: Class 'MemCacheDrupal' not found in ... /includes/cache.inc on line 26
Comment #27
pillarsdotnet commented@mpark: You applied what patch, exactly?
The patch in this issue only changes
README.txt, which is a non-code file and thus can not possibly cause the error you describe.On second thought, please open up a separate issue, as your error can not possibly have any relation to a change in a README file.
Comment #29
Anonymous (not verified) commentedThis instruction does not work:
It gives a
Fatal error: Class 'MemCacheDrupal' not found in includes/cache.incI have to do it like this:
Comment #30
ruloweb commentedSame problem than #29, same fix
Comment #31
helmo commentedFixing the README is discussed in #1536222: Update README.txt for Drupal 7, remove INSTALLATION.txt, lets not further this issue.
Comment #32
NenadP commentedI had issue mentioned in #29, include_once helps, but solved it doing it this way, without includes:
Comment #33
steveoriolSame problem than #29, same fix
Bizarre, I have the issue just for one site inside a set of 5 multi-site for the same drupal instance...
Comment #34
gnal commentedIf you get the error below:
"Fatal error: Class 'MemCacheDrupal' not found in ..."
check the modifications that you have made in your settings.php file.
I had added a line in settings.php for the domain module, and then the configuration settings for memcache, and that was causing the above error. Moving the domain module configuration line to the end of settings.php (after the memcache settings) solved the issue.
Comment #35
asb commentedAccording to #1536222, the README.txt is considered to be correct. Re-opening as instructed in #1536222: Update README.txt for Drupal 7, remove INSTALLATION.txt.
Comment #36
liam morlandI am seeing this problem. I am running 7.x-1.3-rc1. I followed the instructions in the README. I got a WSOD until I added this to the settings:
Comment #37
jeremy commentedI am unable to duplicate. When I copy and paste the recommended configuration from the README into settings.php and test, I do not see this error. Please provide your settings.php so we can figure out what's different.
Comment #38
asb commented"XX" are placeholders for online IP addresses; "FOO" is a key prefix for a live server.
Comment #39
jeremy commentedIn this configuration, this line:
Is overwritten by a later line:
Two possible solutions:
$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';)If the Varnish module is recommending this configuration when defining cache_backends, I suggest you file a bug against it so other people don't run into this same problem.
Comment #40
asb commentedWhen I a) uncomment
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';and b) comment out the twoinclude_once DRUPAL_ROOTlines, and c) make the change suggested in #39, possible solution no. 1, Im getting:If I undo the changes, the site starts working again.
The suggested possible solution no. 2 seems to work without side effects. Thanks!
Comment #41
jeremy commentedIn regards to my first suggestion, it sounds like you changed:
to:
Which is not correct. It should instead have been changed to:
Comment #42
jeremy commentedIf configured as documented, memcache works. Closing.