Пример #1
0
 /**
  * @param ITypeInterface $Type
  * @param bool           $ForceType
  */
 function __construct(ITypeInterface $Type = null, $ForceType = false)
 {
     if ($Type === null) {
         $Type = new Memcached();
     }
     if (!$ForceType) {
         if (!$Type->isAvailable()) {
             $Type = new Memory();
         }
     }
     $this->Type = $Type;
     if ($this->Type->needConfiguration()) {
         if ($this->Type->getConfiguration() !== null) {
             $ConfigCache = new Memory(__METHOD__);
             $Configuration = $ConfigCache->getValue($this->Type->getConfiguration());
             if (false !== $Configuration) {
                 $this->Type->setConfiguration($Configuration);
             } else {
                 $Configuration = parse_ini_file(__DIR__ . '/Configuration.ini', true);
                 if (isset($Configuration[$this->Type->getConfiguration()])) {
                     $Configuration = $Configuration[$this->Type->getConfiguration()];
                 } else {
                     $Configuration = null;
                 }
                 $ConfigCache->setValue($this->Type->getConfiguration(), $Configuration);
                 $this->Type->setConfiguration($Configuration);
             }
         } else {
             $this->Type->setConfiguration(null);
         }
     }
 }
Пример #2
0
 /**
  * @param ITypeInterface $Cache
  */
 function __construct(ITypeInterface $Cache)
 {
     $Rate = $this->getTemplate(__DIR__ . '/Rate.twig');
     $Rate->setVariable('CountHits', $Cache->getHitCount());
     $Rate->setVariable('CountMisses', $Cache->getMissCount());
     $Memory = $this->getTemplate(__DIR__ . '/Memory.twig');
     $Memory->setVariable('SizeAvailable', $Cache->getAvailableSize());
     $Memory->setVariable('SizeUsed', $Cache->getUsedSize());
     $Memory->setVariable('SizeFree', $Cache->getFreeSize());
     $Memory->setVariable('SizeWasted', $Cache->getWastedSize());
     $this->Stage = $Rate->getContent() . $Memory->getContent();
 }
Пример #3
0
 /**
  * @param ITypeInterface $Type
  *
  * @throws \Exception
  */
 function __construct(ITypeInterface $Type = null)
 {
     if ($Type === null) {
         $Type = new Memcached();
     }
     if (!$Type->isAvailable()) {
         $Type = new Apcu();
     }
     if (!$Type->isAvailable()) {
         $Type = new Memory();
     }
     $this->Type = $Type;
     if ($this->Type->needConfiguration() && $this->Type->getConfiguration() !== null) {
         $Configuration = parse_ini_file(__DIR__ . '/Configuration.ini', true);
         if (isset($Configuration[$this->Type->getConfiguration()])) {
             $this->Type->setConfiguration($Configuration[$this->Type->getConfiguration()]);
         } else {
             $this->Type->setConfiguration(null);
         }
     }
 }