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

## Source for file stack.php

Documentation is available at stack.php

1. <?php
2. /**
3. * File containing the ezcCacheStackOptions 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. * Options class for ezcCacheStack instances.
30. *
31. * This options class is used with {@link ezcCacheStack} instances.
32. *
33. * The $configurator property is special, since it only takes effect during
34. * construction of the stack. The idea is, to use this in combination with
35. * {@link ezcCacheManager}. The method {@link }
36. * ezcCacheStackConfigurator::configure()} will called by the constructor of
37. * {@link ezcCacheStack}. Inside this method, the configuration of the stack
38. * can happen as needed. Therefore, the {@link ezcCacheStackableStorage}
39. * instances for the stack do not need to exist when the stack is configured in
40. * the {@link ezcCacheManager}.
41. *
42. * The rest of the options is used as usual to affect the behavior of the
43. * {@link ezcCacheStack}. However, it is highly recommended to not change
44. * $metaStorage and $replacementStrategy once they have been set for a stack.
45. * If these options are changed, the whole stack needs to be resetted using
46. * {@link ezcCacheStack::reset()}. Aside of that, the previous $metaStorage
47. * needs to be resetted.
48. *
49. * @property string $configurator
50. * Name of a class implementing ezcCacheStackConfigurator. This class
51. * will be used right after construction of the stack, to perform
52. * initial configuration. After the construction process, this option
53. * does not have any effect. Null (default) means no configuration.
54. * @property ezcCacheStackMetaDataStorage $metaStorage
55. * This storage will be used to store the meta data of the
56. * replacement strategy used by the stack. If null (default) is
57. * given, the top most storage will be used.
58. * @property string $replacementStrategy
59. * The name of the class given in this property must extend {@link }
60. * ezcCacheReplacementStrategy}. The class will be used as the
61. * replacement strategy in the stack. ezcCacheLruReplacementStrategy
62. * is the default.
63. * @property bool $bubbleUpOnRestore
64. * This option determines if data that is restored from a storage in
65. * the stack will be bubbled up to higher caches. The default here is
66. * false, since it might significantly reduce the {@link }
67. * ezcCacheStack::restore()} performance. In addition, for bubbled up
68. * items, only the attributes will be used that have been provided
69. * while restoring the desired item. Also the lifetime of the item
70. * will practically be reset, since higher storages will start with a
71. * fresh TTL value.
72. * @package Cache
73. * @version //autogen//
74. */
75. class ezcCacheStackOptions extends ezcBaseOptions
76. {
77. /**
78. * Construct a new options object.
79. * Options are constructed from an option array by default. The constructor
80. * automatically passes the given options to the __set() method to set them
81. * in the class.
82. *
83. * @throws ezcBasePropertyNotFoundException
84. * If trying to access a non existent property.
85. * @throws ezcBaseValueException
86. * If the value for a property is out of range.
87. * @param array(string=>mixed) $options The initial options to set.
88. */
89. public function __construct ( array $options = array() )
90. {
91. $this-> properties ['configurator'] = null;
92. $this-> properties ['metaStorage'] = null;
93. $this-> properties ['replacementStrategy'] = 'ezcCacheStackLruReplacementStrategy';
94. $this-> properties ['bubbleUpOnRestore'] = false;
95. parent:: __construct ( $options );
96. }
98. /**
99. * Sets an option.
100. * This method is called when an option is set.
101. *
102. * @param string $propertyName The name of the option to set.
103. * @param mixed $propertyValue The option value.
104. * @ignore
105. *
106. * @throws ezcBasePropertyNotFoundException
107. * if the given property does not exist.
108. * @throws ezcBaseValueException
109. * if the value to be assigned to a property is invalid.
110. * @throws ezcBasePropertyPermissionException
111. * if the property to be set is a read-only property.
112. */
113. public function __set( $propertyName, $propertyValue )
114. {
115. switch ( $propertyName )
116. {
117. case 'configurator':
118. if ( $propertyValue !== null && ( ! is_string ( $propertyValue ) || ( ! class_exists ( $propertyValue ) )
119. || ! in_array ( 'ezcCacheStackConfigurator', class_implements ( $propertyValue ) ) ) )
120. {
121. throw new ezcBaseValueException (
122. $propertyName,
123. $propertyValue,
124. 'existsing class implementing ezcCacheStackConfigurator or null'
125. );
126. }
127. break;
128. case 'metaStorage':
129. if ( $propertyValue !== null && !( $propertyValue instanceof ezcCacheStackMetaDataStorage ) )
130. {
131. throw new ezcBaseValueException (
132. $propertyName,
133. $propertyValue,
134. 'ezcCacheStackMetaDataStorage or null'
135. );
136. }
137. break;
138. case 'replacementStrategy':
139. if ( ! is_string ( $propertyValue ) || ! class_exists ( $propertyValue ) || ! in_array ( 'ezcCacheStackReplacementStrategy', class_implements ( $propertyValue ) ) )
140. {
141. throw new ezcBaseValueException (
142. $propertyName,
143. $propertyValue,
144. 'existing class implementing ezcCacheStackReplacementStrategy'
145. );
146. }
147. break;
148. case 'bubbleUpOnRestore':
149. if ( ! is_bool ( $propertyValue ) )
150. {
151. throw new ezcBaseValueException (
152. $propertyName,
153. $propertyValue,
154. 'bool'
155. );
156. }
157. break;
158. default:
159. throw new ezcBasePropertyNotFoundException ( $propertyName );
160. }
161. $this-> properties [$propertyName] = $propertyValue;
162. }
163. }
165. ?>

Documentation generated by phpDocumentor 1.4.3