Memcache php cli vs apache using different caches? Memcache php cli vs apache using different caches? apache apache

Memcache php cli vs apache using different caches?


When you run CLI PHP, you run it as your user. When you access it through Apache, it runs as the apache user (www-data or similar). memcached actually cares about your username, it will create different caches for different users. So you have two completely separate caches.

You can list these caches using sudo ipcs on Linux, look under Shared Memory Segments. Check out the "owner" column, you'll likely see both. I personally resolve this by running my CLI PHP as the www-data user:

sudo su www-data -c "php lawl.php"