phpcachingmemorycacheapcu

APCU cache on multiple sites of the same server


I am using php-apcu for memory-caching in both sites that are hosted on the same server.

I am getting weird behaviour in some cases, where data from one site is displayed on the other site.

Is it possible that this bug is there because my cache fetches data from what is cached on the other site ? Is APCU cache global for the server, meaning any site on the server can access it ?

Thanks in advance, let me know if something is unclear !


Solution

  • Well, I found this question in the mean time. So I guess the APCU keys are not automatically "locked" per site (which makes sense).

    So, to answer my question: Yes, it is possible that one site fetches data from another site on the same server.

    The fix is to simply pass a unique prefix on each site to your cache keys. The answer to the linked question suggests to use the server host name, personally I use the absolute path to the site's root directory, in order to make sure my cache will work when I use the command line.