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

## Source for file replacement_strategy.php

Documentation is available at replacement_strategy.php

1. <?php
2. /**
3. * File containing the ezcCacheStackReplacementStrategy interface.
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. * Interface to be implemented by stack replacement strategies.
30. *
31. * This interface is to be implemented by replacement strategy classes, which
32. * can be configured to be used by an {@link ezcCacheStack}. The defined
33. * methods wrap around their counterparts on {@link ezcCacheStackableStorage}.
34. *
35. * A replacement strategy must take care about the actual
36. * storing/restoring/deleting of cache items in the given storage. In addition
37. * it must take care about keeping the needed {@link ezcCacheStackMetaData} up
38. * to date and about purging data from the cache storage, if it runs full.
39. *
40. * A replacement strategy must define its own meta data class which implements
41. * {@link ezcCacheStackMetaData}. It must check in each method call, that the
42. * given $metaData is of correct type. If this is not the case, {@link }
43. * ezcCacheInvalidMetaDataException} must be throwen.
44. *
45. * @package Cache
46. * @version //autogentag//
47. */
48. interface ezcCacheStackReplacementStrategy
49. {
50. /**
51. * Stores the given $itemData in the storage given in $conf.
52. *
53. * This method stores the given $itemData assigned to $itemId and
54. * optionally $itemAttributes in the {@link ezcCacheStackableStorage} given
55. * in $conf. In case the storage has reached the $itemLimit defined in
56. * $conf, it must be freed according to $freeRate {@link }
57. * ezcCacheStackStorageConfiguration}.
58. *
59. * The freeing of items from the storage must first happen via {@link }
60. * ezcCacheStackableStorage::purge()}, which removes outdated items from
61. * the storage and returns the affected IDs. In case this does not last to
62. * free the desired number of items, the replacement strategy specific
63. * algorithm for freeing takes effect.
64. *
65. * After the necessary freeing process has been performed, the item is
66. * stored in the storage and the $metaData is updated accordingly.
67. *
68. * @param ezcCacheStackStorageConfiguration $conf
69. * @param ezcCacheStackMetaData $metaData
70. * @param string $itemId
71. * @param mixed $itemData
72. * @param array(string=>string) $itemAttributes
73. * @throws ezcCacheInvalidMetaDataException
74. * if the given $metaData is not processable by this replacement
75. * strategy.
76. */
77. public static function store (
78. ezcCacheStackStorageConfiguration $conf,
79. ezcCacheStackMetaData $metaData,
80. $itemId,
81. $itemData,
82. $itemAttributes = array()
83. );
85. /**
86. * Restores the data with the given $dataId from the storage given in $conf.
87. *
88. * This method takes care of restoring the item with ID $itemId and
89. * optionally $itemAttributes from the {@link ezcCacheStackableStorage}
90. * given in $conf. The parameters $itemId, $itemAttributes and $search are
91. * forwarded to {@link ezcCacheStackableStorage::restore()}, the returned
92. * value (item data on successful restore, otherwise false) are returned by
93. * this method.
94. *
95. * The method must take care that the restore process is reflected in
96. * $metaData according to the spcific replacement strategy implementation.
97. *
98. * @param ezcCacheStackStorageConfiguration $conf
99. * @param ezcCacheStackMetaData $metaData
100. * @param string $itemId
101. * @param array(string=>string) $itemAttributes
102. * @param bool $search
103. *
104. * @return mixed Restored data or false.
105. * @throws ezcCacheInvalidMetaDataException
106. * if the given $metaData is not processable by this replacement
107. * strategy.
108. */
109. public static function restore (
110. ezcCacheStackStorageConfiguration $conf,
111. ezcCacheStackMetaData $metaData,
112. $itemId,
113. $itemAttributes = array(),
114. $search = false
115. );
117. /**
118. * Deletes the data with the given $itemId from the given $storage.
119. *
120. * This method takes care about deleting the item identified by $itemId and
121. * optionally $itemAttributes from the {@link ezcCacheStackableStorage}
122. * give in $conf. The parameters $itemId, $itemAttributes and $search are
123. * therefore forwarded to {@link ezcCacheStackableStorage::delete()}. This
124. * method returns a list of all item IDs that have been deleted by the
125. * call. The method reflects these changes in $metaData.
126. *
127. * @param ezcCacheStackStorageConfiguration $conf
128. * @param ezcCacheStackMetaData $metaData
129. * @param string $itemId
130. * @param array(string=>string) $itemAttributes
131. * @param bool $search
132. *
133. * @return array(string) Deleted item IDs.
134. * @throws ezcCacheInvalidMetaDataException
135. * if the given $metaData is not processable by this replacement
136. * strategy.
137. */
138. public static function delete (
139. ezcCacheStackStorageConfiguration $conf,
140. ezcCacheStackMetaData $metaData,
141. $itemId,
142. $itemAttributes = array(),
143. $search = false
144. );
146. /**
147. * Returns a fresh meta data object.
148. *
149. * Different replacement strategies will use different meta data classes.
150. * This method must return a freshly created instance of the meta data
151. * object used by this meta data.
152. *
153. * @return ezcCacheStackMetaData
154. */
155. public static function createMetaData ();
156. }
158. ?>

Documentation generated by phpDocumentor 1.4.3