1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/lib/Doctrine/ORM/Cache/RegionsConfiguration.php

135 lines
3.3 KiB
PHP
Raw Normal View History

2013-10-03 21:55:55 +04:00
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Cache;
/**
* Cache regions configuration
*
* @since 2.5
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class RegionsConfiguration
{
/**
* @var array
*/
private $lifetimes;
/**
* @var array
*/
private $lockLifetimes;
/**
* @var integer
*/
private $defaultLifetime;
/**
* @var integer
*/
private $defaultLockLifetime;
/**
* @param integer $defaultLifetime
* @param integer $defaultLockLifetime
*/
public function __construct($defaultLifetime = 3600, $defaultLockLifetime = 60)
{
$this->defaultLifetime = $defaultLifetime;
$this->defaultLockLifetime = $defaultLockLifetime;
}
/**
* @return integer
*/
public function getDefaultLifetime()
{
return $this->defaultLifetime;
}
/**
* @param integer $defaultLifetime
*/
public function setDefaultLifetime($defaultLifetime)
{
$this->defaultLifetime = $defaultLifetime;
}
/**
* @return integer
*/
public function getDefaultLockLifetime()
{
return $this->defaultLockLifetime;
}
/**
* @param integer $defaultLockLifetime
*/
public function setDefaultLockLifetime($defaultLockLifetime)
{
$this->defaultLockLifetime = $defaultLockLifetime;
}
/**
* @param string $regionName
*
* @return integer
*/
public function getLifetime($regionName)
{
2013-10-08 02:53:32 +04:00
return isset($this->lifetimes[$regionName])
? $this->lifetimes[$regionName]
: $this->defaultLifetime;
2013-10-03 21:55:55 +04:00
}
/**
* @param string $name
* @param integer $lifetime
*/
public function setLifetime($name, $lifetime)
{
$this->lifetimes[$name] = (integer) $lifetime;
}
/**
* @param string $regionName
*
* @return integer
*/
public function getLockLifetime($regionName)
{
2013-10-08 02:53:32 +04:00
return isset($this->lockLifetimes[$regionName])
? $this->lockLifetimes[$regionName]
: $this->defaultLockLifetime;
2013-10-03 21:55:55 +04:00
}
/**
* @param string $name
* @param integer $lifetime
*/
public function setLockLifetime($name, $lifetime)
{
$this->lockLifetimes[$name] = (integer) $lifetime;
}
}