function HandleDefault()
{
    require_once "Http_Cache.php";
    Http_Cache::setExpires(4 * 60 * 60);
    require_once "FileUtils.php";
    require_once "TreeUtils.php";
    require_once "RubricsData.php";
    require_once "Cache/Lite/Function.php";
    print " ";
    $options = array("cacheDir" => "../tmpcache/", "lifeTime" => 4 * 60 * 60);
    $cache = new Cache_Lite_Function($options);
    $rubrics = new RubricsData();
    $res = $cache->call(array(&$rubrics, "getRootRubrics"));
    //	$res = $rubrics->getRootRubrics();
    $treeBuilder = new TreeBuilder(true, true, "TreeSrcData");
    ob_start();
    $treeBuilder->show($res);
    $_GLOBAL["Tree"] = ob_get_contents();
    ob_end_clean();
    $_GLOBAL["RegionsList"] = "";
    $res = $rubrics->getRegions();
    $_GLOBAL["RegionsList"] .= "<option value=\"0\" selected>Все</option>\n";
    foreach ($res as $r) {
        $_GLOBAL["RegionsList"] .= "<option value=\"" . $r["id"] . "\">" . trim($r["region"]) . "</option>\n";
    }
    $_GLOBAL["UsualStr"] = getUsual("Обычная очередь");
    $_GLOBAL["TestStr"] = getTest("Тестовая очередь");
    $_GLOBAL["SpecStr"] = getSpec("Специальная очередь");
    include "templates/index.html";
}
示例#2
0
<?php

// Test script of Cache_Lite_Function
// $Id: test3.php,v 1.3 2002/09/28 18:05:29 fab Exp $
require_once 'Cache/Lite/Function.php';
$options = array('cacheDir' => '/tmp/', 'lifeTime' => 10);
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_to_bench', 23, 66);
echo $data;
$object = new bench();
$object->test = 666;
$data = $cache->call('object->method_to_bench', 23, 66);
echo $data;
$data = $cache->call('bench::static_method_to_bench', 23, 66);
echo $data;
function function_to_bench($arg1, $arg2)
{
    echo "This is the output of the function function_to_bench({$arg1}, {$arg2}) !<br>";
    return "This is the result of the function function_to_bench({$arg1}, {$arg2}) !<br>";
}
class bench
{
    var $test;
    function method_to_bench($arg1, $arg2)
    {
        echo "\$obj->test = {$this->test} and this is the output of the method \$obj->method_to_bench({$arg1}, {$arg2}) !<br>";
        return "\$obj->test = {$this->test} and this is the result of the method \$obj->method_to_bench({$arg1}, {$arg2}) !<br>";
    }
    function static_method_to_bench($arg1, $arg2)
    {
        echo "This is the output of the function static_method_to_bench({$arg1}, {$arg2}) !<br>";
示例#3
0
 /**
  * If you use the CacheLiteFunction decorator, you may want to invalidate
  * the cache after a change in the data base.
  *
  * @return void
  */
 function cleanCache()
 {
     static $cacheLiteFunction = null;
     if (is_null($cacheLiteFunction)) {
         include_once 'Cache/Lite/Function.php';
         $cacheLiteFunction = new Cache_Lite_Function($this->options['cacheOptions']);
     }
     $cacheLiteFunction->clean($this->options['cacheOptions']['defaultGroup']);
 }
 function fromCache()
 {
     //  parse variable args
     //  method, id, timeout
     //  method, aParams, allFields, key, timeout
     $numArgs = func_num_args();
     if ($numArgs < 2 || $numArgs > 5) {
         return PEAR::raiseError('incorrect args passed');
     }
     $aArgs = func_get_args();
     //  initialise cache object
     $conf = $GLOBALS['_MAX']['CONF'];
     require_once 'Cache/Lite/Function.php';
     //  manually determine timeout required to instantiate cache object
     switch ($numArgs) {
         case 3:
             $timeout = $aArgs[2];
             break;
         case 5:
             $timeout = $aArgs[4];
             break;
         default:
             $timeout = null;
     }
     $method = $aArgs[0];
     $options = array('cacheDir' => MAX_CACHE, 'lifeTime' => isset($timeout) ? $timeout : $conf['delivery']['cacheExpire']);
     // check if this method has defined different cache group
     $cacheGroups = $GLOBALS['_MAX']['Admin_DA']['cacheGroups'];
     // Note: if you change this key, also change the key when clearing the cache in connections-modify.php
     $options['defaultGroup'] = OX_getHostName();
     if (isset($cacheGroups[$method])) {
         $options['defaultGroup'] .= $cacheGroups[$method];
     }
     $cache = new Cache_Lite_Function($options);
     switch ($numArgs) {
         case 2:
         case 3:
             $id = $aArgs[1];
             $timeout = @$aArgs[2];
             // timeout may not be supplied
             // catch stats case
             if (is_array($aArgs[1])) {
                 $aParams = $aArgs[1];
                 $allFields = isset($aArgs[2]) ? $aArgs[2] : false;
                 $ret = $cache->call("Admin_DA::" . $method, $aParams, $allFields);
             } else {
                 $ret = $cache->call("Admin_DA::" . $method, $id);
             }
             break;
         case 4:
         case 5:
             $aParams = $aArgs[1];
             $allFields = $aArgs[2];
             $key = @$aArgs[3];
             $timeout = @$aArgs[4];
             $ret = $cache->call("Admin_DA::" . $method, $aParams, $allFields, $key);
             break;
         default:
             return PEAR::raiseError('incorrect args passed');
     }
     return $ret;
 }
<?php

chdir("/***/YellowPagesGrabber");
require_once "prepend.php";
require_once "RubricsData.php";
require_once "Cache/Lite/Function.php";
error_reporting(E_ALL);
$rubrics =& new RubricsData();
$options = array("cacheDir" => "./tmpcache/", "lifeTime" => 4 * 60 * 60);
$cache = new Cache_Lite_Function($options);
//$expr = "WHERE id > 4268";
$expr = "";
$res =& $rubrics->db->query("SELECT id FROM rubrics {$expr} ORDER BY id ");
//LIMIT 2000
$cache->drop(array(&$rubrics, "getRootRubrics"));
$cache->call(array(&$rubrics, "getRootRubrics"));
while ($row =& $res->fetchRow()) {
    if ($rubrics->isParent($row[0])) {
        print $row[0] . "\n";
        $cache->drop(array(&$rubrics, "getChildrenRubrics"), $row[0]);
        $cache->call(array(&$rubrics, "getChildrenRubrics"), $row[0]);
    }
}
示例#6
0
 /**
  * If you use the CacheLiteFunction decorator, you may want to invalidate
  * the cache after a change in the data base.
  */
 function cleanCache()
 {
     static $cacheLiteFunction = null;
     if (is_null($cacheLiteFunction)) {
         require_once 'Cache/Lite/Function.php';
         $cacheLiteFunction = new Cache_Lite_Function($this->options['cacheOptions']);
     }
     $cacheLiteFunction->clean();
 }