function __construct()
 {
     global $config_vars;
     $shared_memory = new System_SharedMemory();
     if (OPERATING_SYSTEM == 'WIN') {
         //$this->obj = &System_SharedMemory::Factory( 'File', array('tmp' => $config_vars['cache']['dir'] ) );
         $this->obj = $shared_memory->Factory('File', array('tmp' => $config_vars['cache']['dir']));
     } else {
         //$this->obj = &System_SharedMemory::Factory( 'File', array('tmp' => $config_vars['cache']['dir'] ) );
         $this->obj = $shared_memory->Factory('File', array('tmp' => $config_vars['cache']['dir']));
         ////$this->obj = &System_SharedMemory::Factory( 'Systemv', array( 'size' => $size ) ); //Run into size issues all the time.
     }
     return TRUE;
 }
Exemple #2
0
 /**
  * Create a new shared mem object
  *
  * @param string $type  the shared mem type (or false on autodetect)
  * @param array  $options  an associative array of option names and values
  *
  * @return object  a new System_Shared object
  *
  */
 public static function factory($type = false, $options = array())
 {
     if ($type === false) {
         $type = System_SharedMemory::getAvailableTypes(true);
     } else {
         $type = ucfirst(strtolower($type));
     }
     require_once dirname(__FILE__) . '/SharedMemory/' . $type . '.php';
     $class = 'System_SharedMemory_' . $type;
     return new $class($options);
 }
Exemple #3
0
 /**
  * Create a new shared mem object
  *
  * @param string $type  the shared mem type (or false on autodetect)
  * @param array  $options  an associative array of option names and values
  *
  * @return object  a new System_Shared object
  *
  */
 static function &factory($type = false, $options = array())
 {
     if ($type === false) {
         $type = System_SharedMemory::getAvailableTypes(true);
     } else {
         $type = ucfirst(strtolower($type));
     }
     include_once 'SharedMemory/' . $type . '.php';
     $class = 'System_SharedMemory_' . $type;
     $ref = new $class($options);
     return $ref;
 }
Exemple #4
0
<?php

/**
 * 共享内存日志显示文件
 *
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	user
 */
include_once __WEBCOMMON_ROOT . '/SharedMemory/SharedMemory.php';
$objShared = System_SharedMemory::factory();
$arrCache_log = $objShared->get($arrGPdoDB['db_name'] . 'log');
//print_r($arrCache_log);
// 输出到模板
$arrMOutput["smarty_assign"]['arrCache_log'] = $arrCache_log;
Exemple #5
0
function InstantiateClass($path, $class_name)
{
    static $shared;
    $session_id = session_id();
    // Check for global SHM_CACHE setting
    if (!defined('SHM_CACHE') or !SHM_CACHE) {
        //syslog( LOG_DEBUG, "InstantiateClass : not caching {$class_name} for session {$session_id}" );
        include_once $path;
        $x = new ${class_name}();
        return $x;
    }
    if (!isset($shared)) {
        LoadObjectDependency('net.php.pear.System_SharedMemory');
        $shared =& System_SharedMemory::factory();
    }
    include_once $path;
    $x = $shared->get("object-{$class_name}-{$session_id}");
    if (isset($x)) {
        syslog(LOG_DEBUG, 'InstantiateClass : loaded object-' . $class_name . '-' . $session_id . ' from SHM');
        return $x;
    } else {
        $x = new ${class_name}();
        syslog(LOG_DEBUG, 'InstantiateClass : stored object-' . $class_name . '-' . $session_id . ' in SHM');
        $shared->set("object-{$class_name}-{$session_id}", $x);
        return $x;
    }
}
Exemple #6
0
function count_referer($isSave = 1, $uid = null)
{
    global $arrGWeb;
    $objShared = System_SharedMemory::factory();
    if (empty($strVarName)) {
        $strVarName = $arrGWeb['install_date'] . 'referer';
    }
    $arrPayLog = json_decode($objShared->get($strVarName), TRUE);
    if ($isSave == 1) {
        $arrPayLog[$uid] = 1;
    } elseif ($isSave == 0) {
        if (!empty($arrPayLog) && array_key_exists($_SESSION['user_id'], $arrPayLog)) {
            $host = empty($_COOKIE['referer_host']) ? "5217u.com" : $_COOKIE['referer_host'];
            $time = date("Y-m-d");
            $referer = check::getAPI("referer", "getInfoWhere", "where host='{$host}' and time='{$time}'^*");
            if (empty($referer)) {
                $arr_referer = array();
                $arr_referer['time'] = $time;
                $arr_referer['host'] = $host;
                $arr_referer['buy_times'] = 1;
                $str_referer = check::getAPIArray($arr_referer);
                check::getAPI("referer", "saveInfo", "{$str_referer}^0^0");
            } else {
                $referer['buy_times'] += 1;
                $str_referer = check::getAPIArray($referer);
                check::getAPI("referer", "saveInfo", "{$str_referer}^1^0");
            }
            unset($arrPayLog[$_SESSION['user_id']]);
        }
    }
    $objShared->set($strVarName, json_encode($arrPayLog));
    return true;
}