Hi Out there,
I am searching for an solution for an issue to prevent Zend_cache to write a
lot of unnecessary Files if someone
Changes the request in a Loop.
Example:
for($id=0;$id<100000;$id++)
{
someGet(www.website.com?Unknown_nonesense=.$id);
}
As you may already expected I am using the querystring as ID for caching
I am currently thinking about some complicated solutions but maybe somebody
found a simple one *g
Some site Problems :
- No MVC (old Typo3)
- GET Params can change every day -> list of allowed Params is not
possible
Thanks guys
Christoph Hagenbrock
Current Implementation:
<?php
//AGEBROCK IMPLEMENTIERUNG ZEND CACHE
////////////////////-----------------------CACHE start
-------------------------//////////////////////
require_once 'Zend/Cache.php';
/**
* Cache Mock Objekt um den cache zu deaktvieren
* alle dc_Methoden lösen destroyCache aus wenn TRUE
*
* Mock Cache Object to deaktivate Caching
* all dc_methods will dispatch destroyCache id TRUE
*/
class CacheMock
{
function start($id)
{
return false;
}
function end()
{
return true;
}
static function destoryCache()
{
global $cache;
$cache = new CacheMock();
}
/**
* duchsucht das $_GET nach Vorkommen im $config Array
* "*" kann als wildcard genutzt werden.
*
* @param Array $config
*/
static function dc_checkGet($config)
{
foreach ($config as $key => $value)
{
if(isset($_GET[$key]))
{
if($_GET[$key] == $value || $_GET[$key] == '*')
{
self::destoryCache();
return;
}
}
}
}
static function dc_notEmpty($array)
{
if(!empty($array))
{
self::destoryCache();
}
}
}
////////////////////-----------------------CACHE CONFIG
-------------------------//////////////////////
$frontendOptions = array(
'lifetime' => 30, // caching for "x secs"
'automatic_serialization' => false
);
$backendOptions = array(
'cache_dir' => 'fileadmin/zendcache/'
);
$cache = Zend_Cache::factory('Output', 'File', $frontendOptions,
$backendOptions);
////////////////////----------------------- NO CACHE OPTIONS
-------------------------/////////////////
//liste von ID's die nicht gecached werden sollen
$noGetConfig = array(
'id' => 363
);
CacheMock::dc_checkGet($noGetConfig);
CacheMock::dc_notEmpty($_POST);
////////////////////----------------------- NO CACHE HACKS ;)
-------------------------/////////////////
//tradedoubler correction
if(isset($_GET['tduid']))
{
$_SERVER['QUERY_STRING'] = 'agent=td';
}
$id = md5($_SERVER['QUERY_STRING']);
////////////////////----------------------- ENDE CACHE CONTROL
-------------------------/////////////////
/*
Start Sitebuilding
[CODE START]
if (!($cache->start($id))) {
///SITE CREATION ....
$cache->end();
}
[CODE ENDE]
*/
?>