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

## Source for file storage_configuration.php

Documentation is available at storage_configuration.php

1. <?php
2. /**
3. * File containing the ezcCacheStackStorageConfiguration 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. * ezcCacheStackStorageConfiguration
30. *
31. * Configuration for a {@link ezcCacheStackableStorage} inside an {@link }
32. * ezcCacheStack}. The configuration consists of a string $id that identifies
33. * the $storage uniquely inside the stack. The $itemLimit is the maximum number
34. * of items that might be stored in the $storage at once. This number is
35. * determined by the used {@link ezcCacheStackMetaData} used in the stack. The
36. * $freeRate is the fraction of $itemLimit that will be freed by the used
37. * {@link ezcCacheStackReplacementStrategy} when the storage runs full.
38. *
39. * @property-read string $id
40. * The unique ID of the configured storage in the stack.
41. * @property-read ezcCacheStackableStorage $storage
42. * The storage that is configured with this configuration. A
43. * storage might only be part of 1 stack and this only once.
44. * @property-read int $itemLimit
45. * Maximum number of items to be stored in $storage.
46. * @property-read float $freeRate
47. * Fraction of $itemLimit that is freed if $storage runs full.
48. * @package Cache
49. * @version //autogen//
50. */
51. class ezcCacheStackStorageConfiguration
52. {
53. /**
54. * Properties
55. *
56. * @var array(string=>mixed)
57. */
58. protected $properties = array(
59. 'id' => null,
60. 'storage' => null,
61. 'itemLimit' => null,
62. 'freeRate' => null,
63. );
65. /**
66. * Creates a new storage configuration.
67. *
68. * This method creates an new configuration with the given values. Note
69. * that, once set, these values cannot be changed anymore to avoid
70. * inconsistencies in the stack. For details about the parameters, please
71. * refer to the properties documentation of this class.
72. *
73. * Note that the properties can only be set once, using this constructore,
74. * and are not changeable via property access.
75. *
76. * @param string $id
77. * @param ezcCacheStackableStorage $storage
78. * @param int $itemLimit
79. * @param float $freeRate
80. *
81. * @throws ezcBaseValueException
82. * if a given value does not conform to the indicated format.
83. */
84. public function __construct ( $id, ezcCacheStackableStorage $storage, $itemLimit, $freeRate )
85. {
86. if ( ! is_string ( $id ) || strlen ( $id ) < 1 )
87. {
88. throw new ezcBaseValueException (
89. 'id', $id, 'string, length > 0'
90. );
91. }
92. if ( ! is_int ( $itemLimit ) || $itemLimit < 1 )
93. {
94. throw new ezcBaseValueException (
95. 'itemLimit', $itemLimit, 'int > 1'
96. );
97. }
98. if ( ! is_numeric ( $freeRate ) || $freeRate <= 0 || $freeRate > 1 )
99. {
100. throw new ezcBaseValueException (
101. 'freeRate', $freeRate, 'float > 0 and <= 1'
102. );
103. }
104. $this-> properties ['id'] = $id;
105. $this-> properties ['storage'] = $storage;
106. $this-> properties ['itemLimit'] = $itemLimit;
107. $this-> properties ['freeRate'] = $freeRate;
108. }
110. /**
111. * Returns the value of a property.
112. *
113. * @param string $propertyName
114. * @return mixed
115. * @ignore
116. */
117. public function __get( $propertyName )
118. {
119. if ( $this->__isset( $propertyName ) )
120. {
121. return $this-> properties [$propertyName];
122. }
123. throw new ezcBasePropertyNotFoundException ( $propertyName );
124. }
126. /**
127. * Returns if a property exists.
128. *
129. * @param string $propertyName
130. * @return bool
131. * @ignore
132. */
133. public function __isset( $propertyName )
134. {
135. return array_key_exists ( $propertyName, $this-> properties );
136. }
138. /**
139. * Sets a property.
140. *
141. * @param string $propertyName
142. * @param mixed $propertyValue
143. * @ignore
144. */
145. public function __set( $propertyName, $propertyValue )
146. {
147. if ( $this->__isset( $propertyName ) )
148. {
149. throw new ezcBasePropertyPermissionException (
150. $propertyName,
151. ezcBasePropertyPermissionException ::READ
152. );
153. }
154. throw new ezcBasePropertyNotFoundException ( $propertyName );
155. }
156. }
158. ?>

Documentation generated by phpDocumentor 1.4.3