-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCachable.php
More file actions
81 lines (72 loc) · 1.83 KB
/
Copy pathCachable.php
File metadata and controls
81 lines (72 loc) · 1.83 KB
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
<?php
namespace Bdf\Prime\Query\Contract;
use Bdf\Prime\Cache\CacheInterface;
use Bdf\Prime\Cache\CacheKey;
/**
* Cachable query keeps the results into a cache
*/
interface Cachable
{
/**
* Get the configured cache for this query
*
* @return CacheInterface|null
*/
public function cache(): ?CacheInterface;
/**
* Set a cache to the query
*
* @param CacheInterface|null $cache The cache instance, or null to disable cache
*
* @return $this
*/
public function setCache(?CacheInterface $cache = null);
/**
* Enable cache for this query
*
* @param int $lifetime The cache lifetime
* @param string|null $key The cache key. If null, a key will be generated
*
* @return $this
*
* @see Cachable::setCacheLifetime()
* @see Cachable::setCacheKey()
* @see Cachable::setCacheNamespace()
*/
public function useCache(int $lifetime = 0, ?string $key = null);
/**
* Define the cache lifetime
* Enable the cache if not yet enabled
*
* @param int $lifetime The cache lifetime in seconds
*
* @return $this
*/
public function setCacheLifetime(int $lifetime);
/**
* Define the cache key
* Enable the cache if not yet enabled
*
* @param string|null $cacheKey
*
* @return $this
*/
public function setCacheKey(?string $cacheKey);
/**
* Define the cache namespace
* Enable the cache if not yet enabled
*
* The namespace is used to flush cache on write
*
* @param string $namespace
*
* @return $this
*/
public function setCacheNamespace(string $namespace);
/**
* Get the cache key
*
* @return CacheKey|null The cache key, or null if disabled
*/
public function getCacheKey(): ?CacheKey;
}