|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link https://www.yiiframework.com/ |
|
4
|
|
|
* @copyright Copyright (c) 2008 Yii Software LLC |
|
5
|
|
|
* @license https://www.yiiframework.com/license/ |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace yii\caching; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* DummyCache is a placeholder cache component. |
|
12
|
|
|
* |
|
13
|
|
|
* DummyCache does not cache anything. It is provided so that one can always configure |
|
14
|
|
|
* a 'cache' application component and save the check of existence of `\Yii::$app->cache`. |
|
15
|
|
|
* By replacing DummyCache with some other cache component, one can quickly switch from |
|
16
|
|
|
* non-caching mode to caching mode. |
|
17
|
|
|
* |
|
18
|
|
|
* For more details and usage information on Cache, see the [guide article on caching](guide:caching-overview). |
|
19
|
|
|
* |
|
20
|
|
|
* @author Qiang Xue <[email protected]> |
|
21
|
|
|
* @since 2.0 |
|
22
|
|
|
*/ |
|
23
|
|
|
class DummyCache extends Cache |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Retrieves a value from cache with a specified key. |
|
27
|
|
|
* This is the implementation of the method declared in the parent class. |
|
28
|
|
|
* @param string $key a unique key identifying the cached value |
|
29
|
|
|
* @return mixed|false the value stored in cache, false if the value is not in the cache or expired. |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function getValue($key) |
|
32
|
|
|
{ |
|
33
|
|
|
return false; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Stores a value identified by a key in cache. |
|
38
|
|
|
* This is the implementation of the method declared in the parent class. |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $key the key identifying the value to be cached |
|
41
|
|
|
* @param mixed $value the value to be cached |
|
42
|
|
|
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. |
|
43
|
|
|
* @return bool true if the value is successfully stored into cache, false otherwise |
|
44
|
|
|
*/ |
|
45
|
|
|
protected function setValue($key, $value, $duration) |
|
46
|
|
|
{ |
|
47
|
|
|
return true; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Stores a value identified by a key into cache if the cache does not contain this key. |
|
52
|
|
|
* This is the implementation of the method declared in the parent class. |
|
53
|
|
|
* @param string $key the key identifying the value to be cached |
|
54
|
|
|
* @param mixed $value the value to be cached |
|
55
|
|
|
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. |
|
56
|
|
|
* @return bool true if the value is successfully stored into cache, false otherwise |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function addValue($key, $value, $duration) |
|
59
|
|
|
{ |
|
60
|
|
|
return true; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Deletes a value with the specified key from cache |
|
65
|
|
|
* This is the implementation of the method declared in the parent class. |
|
66
|
|
|
* @param string $key the key of the value to be deleted |
|
67
|
|
|
* @return bool if no error happens during deletion |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function deleteValue($key) |
|
70
|
|
|
{ |
|
71
|
|
|
return true; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Deletes all values from cache. |
|
76
|
|
|
* This is the implementation of the method declared in the parent class. |
|
77
|
|
|
* @return bool whether the flush operation was successful. |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function flushValues() |
|
80
|
|
|
{ |
|
81
|
|
|
return true; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|