问题
What's the best option for avoiding key collisions between multiple sites running on the same server using APC for user caching?
I've run into issues where 2 or more sites were using the same cache key and expecting different types of items to be stored under it--one expecting a json string, the other an array, another an object.
Is their a way to segment APC by site?
BTW: I'm using APC with Apache running prefork and mod_php.
回答1:
Perhaps you could append the server hostname to the key, you could define a constant or create some model for handling your APC:
<?php
define('APC_HOST_KEY',$_SERVER['HTTP_HOST']);
apc_store(APC_HOST_KEY.'_value_key', $value);
?>
来源:https://stackoverflow.com/questions/13291244/apc-user-cache-key-collisions-on-multiple-sites