APC用户缓存键在多个站点上发生冲突 [英] APC User Cache Key collisions on multiple sites
问题描述
使用APC进行用户缓存来避免在同一服务器上运行的多个站点之间发生键冲突的最佳选择是什么?
What's the best option for avoiding key collisions between multiple sites running on the same server using APC for user caching?
我遇到了以下问题:两个或多个站点使用相同的缓存键,并期望在其下存储不同类型的项目-一个期望一个json字符串,另一个期望一个数组,另一个期望一个对象.
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.
他们是一种按网站细分APC的方法吗?
Is their a way to segment APC by site?
顺便说一句:我正在APC和Apache上运行prefork和mod_php.
BTW: I'm using APC with Apache running prefork and mod_php.
推荐答案
也许您可以将服务器主机名附加到密钥中,可以定义一个常量或创建一些模型来处理APC:
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);
?>
这篇关于APC用户缓存键在多个站点上发生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!