1 | <?php |
||
12 | class StaticPagesQueue extends DataObject |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | public static $create_table_options = array( |
||
20 | 'MySQLDatabase' => 'ENGINE=InnoDB' |
||
21 | ); |
||
22 | |||
23 | /** |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | public static $db = array( |
||
28 | 'Priority' => 'Int', |
||
29 | 'URLSegment' => 'Varchar(255)', |
||
30 | 'Freshness' => "Enum('stale, regenerating, error', 'stale')" |
||
31 | ); |
||
32 | |||
33 | /** |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | public static $defaults = array( |
||
38 | "Priority" => 3 |
||
39 | ); |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | public static $default_sort = "\"Priority\""; |
||
46 | |||
47 | /** |
||
48 | * Sets database indexes |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | public static $indexes = array( |
||
53 | 'freshness_priority_created' => '(Freshness, Priority, Created)', |
||
54 | ); |
||
55 | |||
56 | /** |
||
57 | * |
||
58 | * @var boolean |
||
59 | */ |
||
60 | private static $realtime = false; |
||
61 | |||
62 | /** |
||
63 | * |
||
64 | * @var int |
||
65 | */ |
||
66 | protected static $minutes_until_force_regeneration = 1; |
||
67 | |||
68 | /** |
||
69 | * |
||
70 | * @var array |
||
71 | */ |
||
72 | protected static $insert_statements = array(); |
||
73 | |||
74 | /** |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected static $urls = array(); |
||
79 | |||
80 | /** |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public static function is_realtime() |
||
88 | |||
89 | /** |
||
90 | * |
||
91 | * @param type $priority |
||
92 | * @param type $URLSegment |
||
93 | * @return type |
||
94 | */ |
||
95 | public static function add_to_queue($priority, $URLSegment) |
||
101 | |||
102 | /** |
||
103 | * This will push all the currently cached insert statements to be pushed |
||
104 | * into the database |
||
105 | * |
||
106 | * @return void |
||
107 | */ |
||
108 | public static function push_urls_to_db() |
||
121 | |||
122 | /** |
||
123 | * Remove an object by the url |
||
124 | * |
||
125 | * @param string $URLSegment |
||
126 | * @return bool - if there was an queue item removed |
||
127 | * |
||
128 | */ |
||
129 | public static function delete_by_link($URLSegment) |
||
140 | |||
141 | /** |
||
142 | * Update the queue with the information that this url renders an error somehow |
||
143 | * |
||
144 | * @param string $url |
||
145 | */ |
||
146 | public static function has_error($url) |
||
156 | |||
157 | /** |
||
158 | * Returns a single queue object according to a particular priority and freshness measure. |
||
159 | * This method removes any duplicates and makes the object as "regenerating", so other calls to this method |
||
160 | * don't grab the same object. |
||
161 | * If we are using MySQLDatabase with InnoDB, we do row-level locking when updating the dataobject to allow for |
||
162 | * distributed cache rebuilds |
||
163 | * @static |
||
164 | * @param $freshness |
||
165 | * @param $sortOrder |
||
166 | */ |
||
167 | protected static function get_queue_object($freshness, $interval = null, $sortOrder = array('Priority'=>'DESC', 'ID'=>'ASC')) |
||
212 | |||
213 | /** |
||
214 | * Finds the next most prioritized url that needs recaching |
||
215 | * |
||
216 | * @return string |
||
217 | */ |
||
218 | public static function get_next_url() |
||
241 | |||
242 | /** |
||
243 | * Removes the .html fresh copy of the cache. |
||
244 | * Keeps the *.stale.html copy in place, |
||
245 | * in order to notify the user of the stale content. |
||
246 | * |
||
247 | * @param array $URLSegments |
||
248 | */ |
||
249 | protected static function remove_old_cache(array $URLSegments) |
||
263 | |||
264 | /** |
||
265 | * Mark this current StaticPagesQueue as a work in progress |
||
266 | * |
||
267 | * @param StaticPagesQueue $object |
||
268 | */ |
||
269 | protected static function mark_as_regenerating(StaticPagesQueue $object) |
||
275 | |||
276 | /** |
||
277 | * Removes all duplicates that has the same URLSegment as $ID |
||
278 | * |
||
279 | * @param int $ID - ID of the object whose duplicates we want to remove |
||
280 | * @return void |
||
281 | */ |
||
282 | public static function remove_duplicates($ID) |
||
292 | |||
293 | /** |
||
294 | * |
||
295 | * @param string $url |
||
296 | * @param bool $onlyStale - Get only stale entries |
||
297 | * @return DataObject || false - The first item matching the query |
||
298 | */ |
||
299 | protected static function get_by_link($url) |
||
308 | } |
||
309 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.