summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/Cache/RegionsConfiguration.php
blob: a8528312b6a8c11197c94bf04d036502021300a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

declare(strict_types=1);

namespace Doctrine\ORM\Cache;

/**
 * Cache regions configuration
 */
class RegionsConfiguration
{
    /** @var array<string,int> */
    private array $lifetimes = [];

    /** @var array<string,int> */
    private array $lockLifetimes = [];

    public function __construct(
        private int $defaultLifetime = 3600,
        private int $defaultLockLifetime = 60,
    ) {
    }

    public function getDefaultLifetime(): int
    {
        return $this->defaultLifetime;
    }

    public function setDefaultLifetime(int $defaultLifetime): void
    {
        $this->defaultLifetime = $defaultLifetime;
    }

    public function getDefaultLockLifetime(): int
    {
        return $this->defaultLockLifetime;
    }

    public function setDefaultLockLifetime(int $defaultLockLifetime): void
    {
        $this->defaultLockLifetime = $defaultLockLifetime;
    }

    public function getLifetime(string $regionName): int
    {
        return $this->lifetimes[$regionName] ?? $this->defaultLifetime;
    }

    public function setLifetime(string $name, int $lifetime): void
    {
        $this->lifetimes[$name] = $lifetime;
    }

    public function getLockLifetime(string $regionName): int
    {
        return $this->lockLifetimes[$regionName] ?? $this->defaultLockLifetime;
    }

    public function setLockLifetime(string $name, int $lifetime): void
    {
        $this->lockLifetimes[$name] = $lifetime;
    }
}