summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/Cache.php
blob: 8020b27546a7ca6d160d6c00b87428916ce6b7e1 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php

declare(strict_types=1);

namespace Doctrine\ORM;

use Doctrine\ORM\Cache\QueryCache;
use Doctrine\ORM\Cache\Region;

/**
 * Provides an API for querying/managing the second level cache regions.
 */
interface Cache
{
    public const DEFAULT_QUERY_REGION_NAME = 'query_cache_region';

    public const DEFAULT_TIMESTAMP_REGION_NAME = 'timestamp_cache_region';

    /**
     * May read items from the cache, but will not add items.
     */
    public const MODE_GET = 1;

    /**
     * Will never read items from the cache,
     * but will add items to the cache as it reads them from the database.
     */
    public const MODE_PUT = 2;

    /**
     * May read items from the cache, and add items to the cache.
     */
    public const MODE_NORMAL = 3;

    /**
     * The query will never read items from the cache,
     * but will refresh items to the cache as it reads them from the database.
     */
    public const MODE_REFRESH = 4;

    public function getEntityCacheRegion(string $className): Region|null;

    public function getCollectionCacheRegion(string $className, string $association): Region|null;

    /**
     * Determine whether the cache contains data for the given entity "instance".
     */
    public function containsEntity(string $className, mixed $identifier): bool;

    /**
     * Evicts the entity data for a particular entity "instance".
     */
    public function evictEntity(string $className, mixed $identifier): void;

    /**
     * Evicts all entity data from the given region.
     */
    public function evictEntityRegion(string $className): void;

    /**
     * Evict data from all entity regions.
     */
    public function evictEntityRegions(): void;

    /**
     * Determine whether the cache contains data for the given collection.
     */
    public function containsCollection(string $className, string $association, mixed $ownerIdentifier): bool;

    /**
     * Evicts the cache data for the given identified collection instance.
     */
    public function evictCollection(string $className, string $association, mixed $ownerIdentifier): void;

    /**
     * Evicts all entity data from the given region.
     */
    public function evictCollectionRegion(string $className, string $association): void;

    /**
     * Evict data from all collection regions.
     */
    public function evictCollectionRegions(): void;

    /**
     * Determine whether the cache contains data for the given query.
     */
    public function containsQuery(string $regionName): bool;

    /**
     * Evicts all cached query results under the given name, or default query cache if the region name is NULL.
     */
    public function evictQueryRegion(string|null $regionName = null): void;

    /**
     * Evict data from all query regions.
     */
    public function evictQueryRegions(): void;

    /**
     * Get query cache by region name or create a new one if none exist.
     *
     * @param string|null $regionName Query cache region name, or default query cache if the region name is NULL.
     */
    public function getQueryCache(string|null $regionName = null): QueryCache;
}