APC and PHP - Broken sites due to cache mixing

Hope someone can let me know how to figure this out. I recently ran APC on some of my servers that host only one application, and it works great. Unfortunately, I went to run it tonight on my workhorse web server, and as soon as I turned it on, I started getting a β€œmix” from my blogs. The first blog to download will cache database information, and then each blog downloaded later will receive a database error.

What I want to know is if there is a way to prefix the cache so that I can avoid this problem. I suggested that the cache will respect differences in the absolute path between files and not use the same cached copy on multiple sites ... FAIL

Thanks in advance!

Update

According to the requested copy of apc.ini file here, which I use in /etc/php.d/ to override the default settings:

/etc/php.d/apc.ini

extension=apc.so apc.shm_size = 64M apc.max_file_size = 8M apc.include_once_override = 1 apc.stat_ctime = 1 
+8
php apc virtualhost opcode
source share
7 answers

As far as I know, you cannot use global settings to set a prefix for different applications. You can change your key names and add a prefix to your names. If you are more experienced, you can use two different php instances using fastcgi, depending on which http server you are using. We do something similar with APC and ngix :)

+6
source share

Have you tried setting apc.file_md5 to On ? Other directives that may make a difference:

Depending on your purpose, I think either apc.file_md5 or apc.canonicalize will help.

+4
source share

Is wordpress adding cache entries to save database queries? If so, you will need to edit the cache library file to include the prefix.

I assume you are using the wordpress plugin? If so, which plugin?

+2
source share

If you use Doctrine ORM and enable APC caching without prefixing, this can cause problems.

In my case, using the Symfony schema and the blind guide to http://symfony-check.org/ led to mixing the APC cache.

Thanks to the guys at Apostrope Now https://groups.google.com/d/msg/apostrophenow/1Z79wc4wjQk/6Vi2jLjP-twJ it seems you need to specify a unique Doctrine cache prefix.

/config/ProjectConfiguration.class.php

  public function configureDoctrine (Doctrine_Manager $ manager)
 {
   $ manager-> setAttribute (Doctrine :: ATTR_QUERY_CACHE, new Doctrine_Cache_Apc (array ('prefix' => 'something_unique'));
 }
+2
source share

Have you tried memory matching? It seems (I'm going to try!), It should work fine and, using php-fpm and pools, it allows you to have different accounts with different caches ...!
Here is a link that may interest you: http://ravirajsblog.blogspot.it/2012/02/php-apc-locking-mechanism.html :)

+1
source share

I have a module that can help you: http://github.com/jamm/memory
There you can use prefixes, key tags and other benefits.
And you can change the cache memory (APC, memcache, shm-memory) without changing the code (one interface for all repositories).

edit: this is for user cache, so it will not fix your problem. You mentioned it late :)

0
source share

I just had to solve this problem. I added the following apc options

 apc.file_md5 = 1 apc.canonicalize = 0 

Not sure if this helped or the variable I added to the file. In my case, however, it was a mixture of files under the same web root that existed in different ways, have the same name and the same "header".

0
source share

All Articles