forked from Gregwar/Cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CacheInterface.php
131 lines (115 loc) · 3.71 KB
/
CacheInterface.php
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php namespace Gregwar\Cache;
interface CacheInterface {
/**
* Sets the cache directory
*
* @param string $cacheDirectory the cache directory
* @return self
*/
public function setCacheDirectory($cacheDirectory);
/**
* Gets the cache directory
*
* @return string the cache directory
*/
public function getCacheDirectory();
/**
* Sets the actual cache directory
*
* @param string|null $actualCacheDirectory the actual cache directory
* @return self
*/
public function setActualCacheDirectory($actualCacheDirectory = null);
/**
* Returns the actual cache directory
*/
public function getActualCacheDirectory();
/**
* Change the prefix size
*
* @param int $prefixSize the size of the prefix directories
* @return self
*/
public function setPrefixSize($prefixSize);
/**
* Change the directory mode
*
* @param int $directoryMode the directory mode to use
* @return self
*/
public function setDirectoryMode($directoryMode);
/**
* Gets the cache file name
*
* @param string $filename the name of the cache file
* @param bool $actual get the actual file or the public file
* @param bool $mkdir a boolean to enable/disable the construction of the
* cache file directory
* @return string
*/
public function getCacheFile($filename, $actual = false, $mkdir = false);
/**
* Checks if the target filename exists in the cache and if the conditions
* are respected
*
* @param string $filename the filename
* @param array $conditions the conditions to respect
* @return bool
*/
public function exists($filename, array $conditions = array());
/**
* Alias for exists
*
* @param string $filename the filename
* @param array $conditions the conditions to respect
* @return bool
*/
public function check($filename, array $conditions = array());
/**
* Write data in the cache
*
* @param string $filename the name of the cache file
* @param string $contents the contents to store
* @return self
*/
public function set($filename, $contents = '');
/**
* Alias for set()
*
* @param string $filename the name of the cache file
* @param string $contents the contents to store
* @return self
*/
public function write($filename, $contents = '');
/**
* Get data from the cache
*
* @param string $filename the cache file name
* @param array $conditions
* @return null|string
*/
public function get($filename, array $conditions = array());
/**
* Get or create the cache entry
*
* @param string $filename the cache file name
* @param array $conditions an array of conditions about expiration
* @param \Closure $function the closure to call if the file does not exist
* @param bool $file returns the cache file or the file contents
* @param bool $actual returns the actual cache file
* @return string
* @throws \InvalidArgumentException
*/
public function getOrCreate($filename, array $conditions, $function, $file = false, $actual = false);
/**
* Alias to getOrCreate with $file = true
*
* @param string $filename the cache file name
* @param array $conditions an array of conditions about expiration
* @param \Closure $function the closure to call if the file does not exist
* @param bool $actual returns the actual cache file
* @return string
* @throws \InvalidArgumentException
*/
public function getOrCreateFile($filename, array $conditions, $function, $actual = false);
}