## Apache Zeta Components Manual :: File Source for storage_file.php

## Source for file storage_file.php

Documentation is available at storage_file.php

1. <?php
2. /**
3. * File containing the ezcCacheStorageFileOptions class.
4. *
5. * Licensed to the Apache Software Foundation (ASF) under one
6. * or more contributor license agreements. See the NOTICE file
7. * distributed with this work for additional information
8. * regarding copyright ownership. The ASF licenses this file
9. * to you under the Apache License, Version 2.0 (the
10. * "License"); you may not use this file except in compliance
11. * with the License. You may obtain a copy of the License at
12. *
13. * http://www.apache.org/licenses/LICENSE-2.0
14. *
15. * Unless required by applicable law or agreed to in writing,
16. * software distributed under the License is distributed on an
17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18. * KIND, either express or implied. See the License for the
19. * specific language governing permissions and limitations
20. * under the License.
21. *
22. * @package Cache
23. * @version //autogentag//
24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
25. * @filesource
26. */
28. /**
29. * Option class for the ezcCacheStorageFile class.
30. * Instances of this class store the option of ezcCacheStorageFile implementations.
31. *
32. * @property int $ttl
33. * The time to live of cache entries.
34. * @property string $extension
35. * The (file) extension to use for the storage items.
36. * @property int $permissions
37. * Permissions to create a file with (Posix only).
38. * @property string $lockFile
39. * The name of the file used for locking in the lock() method.
40. * Default is '.ezcLock'.
41. * @property int $lockWaitTime
42. * Time to wait between lock availability checks. Measured in
43. * microseconds ({@link usleep()}). Default is 200000.
44. * @property int $maxLockTime
45. * Time before a lock is considered dead, measured in seconds.
46. * Default is 5.
47. * @property string $metaDataFile
48. * The name of the file used to store meta data. Default is
49. * '.ezcMetaData'.
50. *
51. * @package Cache
52. * @version //autogentag//
53. */
54. class ezcCacheStorageFileOptions extends ezcBaseOptions
55. {
56. /**
57. * Parent storage options.
58. *
59. * @var ezcCacheStorageOptions
60. */
61. protected $storageOptions ;
63. /**
64. * Constructs a new options class.
65. *
66. * It also sets the default values of the format property
67. *
68. * @param array(string=>mixed) $options The initial options to set.
70. * @throws ezcBasePropertyNotFoundException
71. * If trying to assign a property which does not exist
72. * @throws ezcBaseValueException
73. * If the value for the property is incorrect
74. */
75. public function __construct ( $options = array() )
76. {
77. $this-> properties ['permissions'] = 0644;
78. $this-> properties ['lockFile'] = '.ezcLock';
79. $this-> properties ['lockWaitTime'] = 200000;
80. $this-> properties ['maxLockTime'] = 5;
81. $this-> properties ['lockFile'] = '.ezcLock';
82. $this-> properties ['metaDataFile'] = '.ezcMetaData';
83. $this-> storageOptions = new ezcCacheStorageOptions ();
84. parent:: __construct ( $options );
85. }
87. /**
88. * Sets an option.
89. * This method is called when an option is set.
90. *
91. * @param string $key The option name.
92. * @param mixed $value The option value.
93. * @ignore
94. */
95. public function __set( $key, $value )
96. {
97. switch ( $key )
98. {
99. case "permissions":
100. if ( ! is_int ( $value ) || $value < 0 || $value > 0777 )
101. {
102. throw new ezcBaseValueException ( $key, $value, "int > 0 and <= 0777" );
103. }
104. break;
105. case "lockFile":
106. if ( ! is_string ( $value ) || strlen ( $value ) < 1 || strlen ( $value ) > 250 )
107. {
108. throw new ezcBaseValueException (
109. $key,
110. $value,
111. 'string, length > 0 and < 250'
112. );
113. }
114. break;
115. case "lockWaitTime":
116. if ( ! is_int ( $value ) || $value < 1 )
117. {
118. throw new ezcBaseValueException (
119. $key,
120. $value,
121. 'int > 0'
122. );
123. }
124. break;
125. case "maxLockTime":
126. if ( ! is_int ( $value ) || $value < 1 )
127. {
128. throw new ezcBaseValueException (
129. $key,
130. $value,
131. 'int > 0'
132. );
133. }
134. break;
135. case "metaDataFile":
136. if ( ! is_string ( $value ) || strlen ( $value ) < 1 || strlen ( $value ) > 250 )
137. {
138. throw new ezcBaseValueException (
139. $key,
140. $value,
141. 'string, length > 0 and < 250'
142. );
143. }
144. break;
145. // Delegate
146. default:
147. $this-> storageOptions ->$key = $value;
148. return;
149. }
150. $this-> properties [$key] = $value;
151. }
153. /**
154. * Property get access.
155. * Simply returns a given option.
156. *
157. * @throws ezcBasePropertyNotFoundException
158. * If trying to assign a property which does not exist
159. * @param string $key The name of the option to get.
160. * @return mixed The option value.
161. * @ignore
162. */
163. public function __get( $key )
164. {
165. if ( isset( $this-> properties [$key] ) )
166. {
167. return $this-> properties [$key];
168. }
169. // Delegate
170. return $this-> storageOptions ->$key;
171. }
173. /**
174. * Returns if a option exists.
175. *
176. * @param string $key Option name to check for.
177. * @return void
178. * @ignore
179. */
180. public function __isset( $key )
181. {
182. // Delegate
183. return ( array_key_exists ( $key, $this-> properties ) || isset( $this-> storageOptions ->$key ) );
184. }
186. /**
187. * Merge an ezcCacheStorageOptions object into this object.
188. *
189. * @param ezcCacheStorageOptions $options The options to merge.
190. * @return void
191. * @ignore
192. */
193. public function mergeStorageOptions( ezcCacheStorageOptions $options )
194. {
195. $this-> storageOptions = $options;
196. }
197. }
199. ?>

Documentation generated by phpDocumentor 1.4.3