@@ -86,7 +86,6 @@ public static function create(
8686 $ stmt ->bindParam (":content " , $ content , PDO ::PARAM_STR );
8787 $ successful = $ stmt ->execute ();
8888 $ stmt ->closeCursor ();
89- if ($ successful ) Common::$ cache ->delete ("bnetdocs-newsposts " );
9089 } catch (PDOException $ e ) {
9190 throw new QueryException ("Cannot create news post " , $ e );
9291 } finally {
@@ -107,10 +106,6 @@ public static function delete($id) {
107106 $ stmt ->bindParam (":id " , $ id , PDO ::PARAM_INT );
108107 $ successful = $ stmt ->execute ();
109108 $ stmt ->closeCursor ();
110- if ($ successful ) {
111- Common::$ cache ->delete ("bnetdocs-newspost- " . (int ) $ id );
112- Common::$ cache ->delete ("bnetdocs-newsposts " );
113- }
114109 } catch (PDOException $ e ) {
115110 throw new QueryException ("Cannot delete news post " , $ e );
116111 } finally {
@@ -120,16 +115,6 @@ public static function delete($id) {
120115 }
121116
122117 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- }
133118 if (!isset (Common::$ database )) {
134119 Common::$ database = DatabaseDriver::getDatabaseObject ();
135120 }
@@ -156,17 +141,11 @@ public static function getAllNews($reverse) {
156141 if (!$ stmt ->execute ()) {
157142 throw new QueryException ("Cannot refresh news post " );
158143 }
159- $ ids = [];
160144 $ objects = [];
161145 while ($ row = $ stmt ->fetch (PDO ::FETCH_OBJ )) {
162- $ ids [] = (int ) $ row ->id ;
163146 $ objects [] = new self ($ row );
164- Common::$ cache ->set (
165- "bnetdocs-newspost- " . $ row ->id , serialize ($ row ), 300
166- );
167147 }
168148 $ stmt ->closeCursor ();
169- Common::$ cache ->set ($ cache_key , implode (", " , $ ids ), 300 );
170149 return $ objects ;
171150 } catch (PDOException $ e ) {
172151 throw new QueryException ("Cannot refresh news post " , $ e );
@@ -198,14 +177,9 @@ public static function getNewsPostsByUserId($user_id) {
198177 if (!$ stmt ->execute ()) {
199178 throw new QueryException ("Cannot query news posts by user id " );
200179 }
201- $ ids = [];
202180 $ objects = [];
203181 while ($ row = $ stmt ->fetch (PDO ::FETCH_OBJ )) {
204- $ ids [] = (int ) $ row ->id ;
205182 $ objects [] = new self ($ row );
206- Common::$ cache ->set (
207- "bnetdocs-newspost- " . $ row ->id , serialize ($ row ), 300
208- );
209183 }
210184 $ stmt ->closeCursor ();
211185 return $ objects ;
@@ -328,20 +302,6 @@ protected static function normalize(StdClass &$data) {
328302 }
329303
330304 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- }
345305 if (!isset (Common::$ database )) {
346306 Common::$ database = DatabaseDriver::getDatabaseObject ();
347307 }
@@ -378,7 +338,6 @@ public function refresh() {
378338 $ this ->options_bitmask = $ row ->options_bitmask ;
379339 $ this ->title = $ row ->title ;
380340 $ this ->user_id = $ row ->user_id ;
381- Common::$ cache ->set ($ cache_key , serialize ($ row ), 300 );
382341 return true ;
383342 } catch (PDOException $ e ) {
384343 throw new QueryException ("Cannot refresh news post " , $ e );
@@ -428,22 +387,6 @@ public function save() {
428387 throw new QueryException ("Cannot save news post " );
429388 }
430389 $ 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-
447390 return true ;
448391 } catch (PDOException $ e ) {
449392 throw new QueryException ("Cannot save news post " , $ e );
0 commit comments