/**
  * @param string
  * @param option { hosts=>array( array('name'=>'localhost','port'=>11211)) }
  */
 function __construct($name, $option)
 {
     parent::__construct($name, $option);
     $this->mm = new Memcached();
     if (is_array($option['hosts'])) {
         foreach ($option['hosts'] as $host) {
             $this->mm->addServer($host['name'], $host['port']);
         }
     }
 }
Exemple #2
0
 /**
  * Initialize
  */
 function init()
 {
     $CH = NyaaCache::current();
     if (self::RELEASE === false || false === ($AppInfo = $CH->get('appinfo', $option))) {
         $AppInfo = unserialize(file_get_contents($this->Conf->rootDir . '/var/installed'));
         $CH->set('appinfo', $AppInfo);
     }
     $this->AppInfo = $AppInfo;
     // Get Current Application Name
     $this->set('env.app', $this->parseAppName($this->Request->getOr('app', $this->Conf->appDefault)));
 }
Exemple #3
0
 /**
  * @param string
  * @param option { path=>'/tmp }
  */
 function __construct($name, $option)
 {
     parent::__construct($name, $option);
     $this->path = $option['path'];
     $this->name = $name;
 }
 function __construct()
 {
     $this->mm = NyaaCache::current();
 }
Exemple #5
0
<?php

$c = NyaaCache::factory('memcached', 'test', array('hosts' => array(array('name' => 'localhost', 'port' => 11211))));
$c = NyaaCache::factory('dir', 'test', array('path' => ROOT . '/site/cache'));
$c->set('a', 'aaaa', 40);
$c->set('b', '111', 40);
$c->set('c', new stdclass(), 40);
var_dump($c->get('a'));
var_dump($c->get('b'));
var_dump($c->get('c'));
Exemple #6
0
 function loadMessage($file)
 {
     $CH = NyaaCache::current();
     if (self::RELEASE === false || false === ($msg = $CH->get($file))) {
         $label = false;
         $buf = array();
         $arr = array();
         foreach (file($file) as $line) {
             $line = trim($line);
             if ($line == ".") {
                 $arr[$label] = implode("\n", $buf);
                 $buf = array();
                 $label = false;
                 continue;
             }
             if ($label == false && $line[strlen($line) - 1] == ":") {
                 $label = substr($line, 0, strlen($line) - 1);
                 continue;
             }
             if ($label !== false) {
                 $buf[] = $line;
             }
         }
         $msg = $arr;
         $CH->set($file, $msg);
     }
     $this->message = array_merge($this->message, $msg);
 }
Exemple #7
0
<?php

define('ROOT', realpath('../'));
set_include_path(ROOT . '/lib');
//--------------------------------
// Setup Cache Handler
//--------------------------------
require_once 'cache/cache.class.php';
NyaaCache::stack(NyaaCache::factory('dir', 'CACHE', array('path' => ROOT . '/site/var/cache')));
//--------------------------------
// Setup Log Handler
//--------------------------------
require_once 'log/log.class.php';
$_NYAA_LOG = array();
$logger = new NyaaLog();
$handler = $logger->createHandler('capture');
$handler->bind($_NYAA_LOG);
$logger->addHandler(NyaaLog::ALL, $handler);
NyaaLog::addStack($logger);
//--------------------------------
// Setup Session
//--------------------------------
require_once 'fw/session.handler.class.php';
$ses = new NyaaSessionHandler();
session_set_save_handler(array($ses, 'open'), array($ses, 'close'), array($ses, 'read'), array($ses, 'write'), array($ses, 'destroy'), array($ses, 'gc'));
session_start();