@@ -86,7 +86,6 @@ public static function create(
86
86
$ stmt ->bindParam (":content " , $ content , PDO ::PARAM_STR );
87
87
$ successful = $ stmt ->execute ();
88
88
$ stmt ->closeCursor ();
89
- if ($ successful ) Common::$ cache ->delete ("bnetdocs-newsposts " );
90
89
} catch (PDOException $ e ) {
91
90
throw new QueryException ("Cannot create news post " , $ e );
92
91
} finally {
@@ -107,10 +106,6 @@ public static function delete($id) {
107
106
$ stmt ->bindParam (":id " , $ id , PDO ::PARAM_INT );
108
107
$ successful = $ stmt ->execute ();
109
108
$ stmt ->closeCursor ();
110
- if ($ successful ) {
111
- Common::$ cache ->delete ("bnetdocs-newspost- " . (int ) $ id );
112
- Common::$ cache ->delete ("bnetdocs-newsposts " );
113
- }
114
109
} catch (PDOException $ e ) {
115
110
throw new QueryException ("Cannot delete news post " , $ e );
116
111
} finally {
@@ -120,16 +115,6 @@ public static function delete($id) {
120
115
}
121
116
122
117
public static function getAllNews ($ reverse ) {
123
- $ cache_key = "bnetdocs-newsposts " ;
124
- $ cache_val = Common::$ cache ->get ($ cache_key );
125
- if ($ cache_val !== false && !empty ($ cache_val )) {
126
- $ ids = explode (", " , $ cache_val );
127
- $ objects = [];
128
- foreach ($ ids as $ id ) {
129
- $ objects [] = new self ($ id );
130
- }
131
- return $ objects ;
132
- }
133
118
if (!isset (Common::$ database )) {
134
119
Common::$ database = DatabaseDriver::getDatabaseObject ();
135
120
}
@@ -156,17 +141,11 @@ public static function getAllNews($reverse) {
156
141
if (!$ stmt ->execute ()) {
157
142
throw new QueryException ("Cannot refresh news post " );
158
143
}
159
- $ ids = [];
160
144
$ objects = [];
161
145
while ($ row = $ stmt ->fetch (PDO ::FETCH_OBJ )) {
162
- $ ids [] = (int ) $ row ->id ;
163
146
$ objects [] = new self ($ row );
164
- Common::$ cache ->set (
165
- "bnetdocs-newspost- " . $ row ->id , serialize ($ row ), 300
166
- );
167
147
}
168
148
$ stmt ->closeCursor ();
169
- Common::$ cache ->set ($ cache_key , implode (", " , $ ids ), 300 );
170
149
return $ objects ;
171
150
} catch (PDOException $ e ) {
172
151
throw new QueryException ("Cannot refresh news post " , $ e );
@@ -198,14 +177,9 @@ public static function getNewsPostsByUserId($user_id) {
198
177
if (!$ stmt ->execute ()) {
199
178
throw new QueryException ("Cannot query news posts by user id " );
200
179
}
201
- $ ids = [];
202
180
$ objects = [];
203
181
while ($ row = $ stmt ->fetch (PDO ::FETCH_OBJ )) {
204
- $ ids [] = (int ) $ row ->id ;
205
182
$ objects [] = new self ($ row );
206
- Common::$ cache ->set (
207
- "bnetdocs-newspost- " . $ row ->id , serialize ($ row ), 300
208
- );
209
183
}
210
184
$ stmt ->closeCursor ();
211
185
return $ objects ;
@@ -328,20 +302,6 @@ protected static function normalize(StdClass &$data) {
328
302
}
329
303
330
304
public function refresh () {
331
- $ cache_key = "bnetdocs-newspost- " . $ this ->id ;
332
- $ cache_val = Common::$ cache ->get ($ cache_key );
333
- if ($ cache_val !== false ) {
334
- $ cache_val = unserialize ($ cache_val );
335
- $ this ->category_id = $ cache_val ->category_id ;
336
- $ this ->content = $ cache_val ->content ;
337
- $ this ->created_datetime = $ cache_val ->created_datetime ;
338
- $ this ->edited_count = $ cache_val ->edited_count ;
339
- $ this ->edited_datetime = $ cache_val ->edited_datetime ;
340
- $ this ->options_bitmask = $ cache_val ->options_bitmask ;
341
- $ this ->title = $ cache_val ->title ;
342
- $ this ->user_id = $ cache_val ->user_id ;
343
- return true ;
344
- }
345
305
if (!isset (Common::$ database )) {
346
306
Common::$ database = DatabaseDriver::getDatabaseObject ();
347
307
}
@@ -378,7 +338,6 @@ public function refresh() {
378
338
$ this ->options_bitmask = $ row ->options_bitmask ;
379
339
$ this ->title = $ row ->title ;
380
340
$ this ->user_id = $ row ->user_id ;
381
- Common::$ cache ->set ($ cache_key , serialize ($ row ), 300 );
382
341
return true ;
383
342
} catch (PDOException $ e ) {
384
343
throw new QueryException ("Cannot refresh news post " , $ e );
@@ -428,22 +387,6 @@ public function save() {
428
387
throw new QueryException ("Cannot save news post " );
429
388
}
430
389
$ stmt ->closeCursor ();
431
-
432
- $ object = new StdClass ();
433
- $ object ->category_id = $ this ->category_id ;
434
- $ object ->content = $ this ->content ;
435
- $ object ->created_datetime = $ this ->created_datetime ;
436
- $ object ->edited_count = $ this ->edited_count ;
437
- $ object ->edited_datetime = $ this ->edited_datetime ;
438
- $ object ->id = $ this ->id ;
439
- $ object ->options_bitmask = $ this ->options_bitmask ;
440
- $ object ->title = $ this ->title ;
441
- $ object ->user_id = $ this ->user_id ;
442
-
443
- $ cache_key = "bnetdocs-newspost- " . $ this ->id ;
444
- Common::$ cache ->set ($ cache_key , serialize ($ object ), 300 );
445
- Common::$ cache ->delete ("bnetdocs-newsposts " );
446
-
447
390
return true ;
448
391
} catch (PDOException $ e ) {
449
392
throw new QueryException ("Cannot save news post " , $ e );
0 commit comments