knot-lib/cache

View on GitHub
src/config/CacheConfigBase.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
declare(strict_types=1);

namespace knotlib\cache\config;

use knotlib\config\Config;

class CacheConfigBase
{
    const KEY_CACHE_EXPIRE    = 'cache/expire';
    
    const DEFAULT_EXPIRE   = 60;  // expires 60 seconds after by default

    /** @var int */
    private $expire;
    
    /**
     * Container constructor.
     *
     * @param array $config
     */
    public function __construct(array $config)
    {
        $config = new Config($config);
        $this->expire      = $config->getInteger(self::KEY_CACHE_EXPIRE, self::DEFAULT_EXPIRE);
    }

    /**
     *  Get cache expire time in milli seconds
     *
     * @return int
     */
    public function getExpire() : int
    {
        return $this->expire;
    }
}