@@ -86,8 +86,6 @@ public static function create($parent_type, $parent_id, $user_id, $content) {
86
86
} catch (PDOException $ e ) {
87
87
throw new QueryException ("Cannot create comment " , $ e );
88
88
} finally {
89
- $ ck = "bnetdocs-comment- " . $ parent_type . "- " . $ parent_id ;
90
- Common::$ cache ->delete ($ ck );
91
89
return $ successful ;
92
90
}
93
91
}
@@ -104,12 +102,6 @@ public static function delete($id, $parent_type, $parent_id) {
104
102
$ stmt ->bindParam (":id " , $ id , PDO ::PARAM_INT );
105
103
$ successful = $ stmt ->execute ();
106
104
$ stmt ->closeCursor ();
107
- if ($ successful ) {
108
- Common::$ cache ->delete ("bnetdocs-comment- " . (int ) $ id );
109
- Common::$ cache ->delete (
110
- "bnetdocs-comment- " . (int ) $ parent_type . "- " . (int ) $ parent_id
111
- );
112
- }
113
105
} catch (PDOException $ e ) {
114
106
throw new QueryException ("Cannot delete comment " , $ e );
115
107
} finally {
@@ -118,16 +110,6 @@ public static function delete($id, $parent_type, $parent_id) {
118
110
}
119
111
120
112
public static function getAll ($ parent_type , $ parent_id ) {
121
- $ ck = "bnetdocs-comment- " . $ parent_type . "- " . $ parent_id ;
122
- $ cv = Common::$ cache ->get ($ ck );
123
- if ($ cv !== false && !empty ($ cv )) {
124
- $ ids = explode (", " , $ cv );
125
- $ objects = [];
126
- foreach ($ ids as $ id ) {
127
- $ objects [] = new self ($ id );
128
- }
129
- return $ objects ;
130
- }
131
113
if (!isset (Common::$ database )) {
132
114
Common::$ database = DatabaseDriver::getDatabaseObject ();
133
115
}
@@ -156,17 +138,11 @@ public static function getAll($parent_type, $parent_id) {
156
138
if (!$ stmt ->execute ()) {
157
139
throw new QueryException ("Cannot refresh comment " );
158
140
}
159
- $ ids = [];
160
141
$ objects = [];
161
142
while ($ row = $ stmt ->fetch (PDO ::FETCH_OBJ )) {
162
- $ ids [] = (int ) $ row ->id ;
163
143
$ objects [] = new self ($ row );
164
- Common::$ cache ->set (
165
- "bnetdocs-comment- " . $ row ->id , serialize ($ row ), self ::CACHE_TTL
166
- );
167
144
}
168
145
$ stmt ->closeCursor ();
169
- Common::$ cache ->set ($ ck , implode (", " , $ ids ), self ::CACHE_TTL );
170
146
return $ objects ;
171
147
} catch (PDOException $ e ) {
172
148
throw new QueryException ("Cannot refresh comment " , $ e );
@@ -267,20 +243,6 @@ protected static function normalize(StdClass &$data) {
267
243
}
268
244
269
245
public function refresh () {
270
- $ ck = "bnetdocs-comment- " . $ this ->id ;
271
- $ cv = Common::$ cache ->get ($ ck );
272
- if ($ cv !== false ) {
273
- $ cv = unserialize ($ cv );
274
- $ this ->content = $ cv ->content ;
275
- $ this ->created_datetime = $ cv ->created_datetime ;
276
- $ this ->edited_count = $ cv ->edited_count ;
277
- $ this ->edited_datetime = $ cv ->edited_datetime ;
278
- $ this ->id = $ cv ->id ;
279
- $ this ->parent_id = $ cv ->parent_id ;
280
- $ this ->parent_type = $ cv ->parent_type ;
281
- $ this ->user_id = $ cv ->user_id ;
282
- return true ;
283
- }
284
246
if (!isset (Common::$ database )) {
285
247
Common::$ database = DatabaseDriver::getDatabaseObject ();
286
248
}
@@ -316,7 +278,6 @@ public function refresh() {
316
278
$ this ->parent_id = $ row ->parent_id ;
317
279
$ this ->parent_type = $ row ->parent_type ;
318
280
$ this ->user_id = $ row ->user_id ;
319
- Common::$ cache ->set ($ ck , serialize ($ row ), self ::CACHE_TTL );
320
281
return true ;
321
282
} catch (PDOException $ e ) {
322
283
throw new QueryException ("Cannot refresh comment " , $ e );
@@ -356,25 +317,6 @@ public function save() {
356
317
throw new QueryException ( 'Cannot save comment ' );
357
318
}
358
319
$ stmt ->closeCursor ();
359
-
360
- $ object = new StdClass ();
361
- $ object ->content = $ this ->content ;
362
- $ object ->created_datetime = $ this ->created_datetime ;
363
- $ object ->edited_count = $ this ->edited_count ;
364
- $ object ->edited_datetime = $ this ->edited_datetime ;
365
- $ object ->id = $ this ->id ;
366
- $ object ->parent_id = $ this ->parent_id ;
367
- $ object ->parent_type = $ this ->parent_type ;
368
- $ object ->user_id = $ this ->user_id ;
369
-
370
- Common::$ cache ->set (
371
- 'bnetdocs-comment- ' . $ this ->id , serialize ( $ object ), self ::CACHE_TTL
372
- );
373
-
374
- Common::$ cache ->delete (
375
- 'bnetdocs-comment- ' . $ this ->parent_type . '- ' . $ this ->parent_id
376
- );
377
-
378
320
return true ;
379
321
} catch ( PDOException $ e ) {
380
322
throw new QueryException ( 'Cannot save comment ' , $ e );
0 commit comments