@@ -78,7 +78,6 @@ public static function create(
78
78
$ stmt ->bindParam (":content " , $ content , PDO ::PARAM_STR );
79
79
$ successful = $ stmt ->execute ();
80
80
$ stmt ->closeCursor ();
81
- if ($ successful ) Common::$ cache ->delete ("bnetdocs-documents " );
82
81
} catch (PDOException $ e ) {
83
82
throw new QueryException ("Cannot create document " , $ e );
84
83
} finally {
@@ -99,10 +98,6 @@ public static function delete($id) {
99
98
$ stmt ->bindParam (":id " , $ id , PDO ::PARAM_INT );
100
99
$ successful = $ stmt ->execute ();
101
100
$ stmt ->closeCursor ();
102
- if ($ successful ) {
103
- Common::$ cache ->delete ("bnetdocs-document- " . (int ) $ id );
104
- Common::$ cache ->delete ("bnetdocs-documents " );
105
- }
106
101
} catch (PDOException $ e ) {
107
102
throw new QueryException ("Cannot delete document " , $ e );
108
103
} finally {
@@ -112,16 +107,6 @@ public static function delete($id) {
112
107
}
113
108
114
109
public static function getAllDocuments ( $ order = null ) {
115
- $ cache_key = 'bnetdocs-documents- ' . hash ('md5 ' , $ order [0 ] . $ order [1 ]);
116
- $ cache_val = Common::$ cache ->get ($ cache_key );
117
- if ($ cache_val !== false && !empty ($ cache_val )) {
118
- $ ids = explode (", " , $ cache_val );
119
- $ objects = [];
120
- foreach ($ ids as $ id ) {
121
- $ objects [] = new self ($ id );
122
- }
123
- return $ objects ;
124
- }
125
110
if (!isset (Common::$ database )) {
126
111
Common::$ database = DatabaseDriver::getDatabaseObject ();
127
112
}
@@ -144,17 +129,11 @@ public static function getAllDocuments( $order = null ) {
144
129
if (!$ stmt ->execute ()) {
145
130
throw new QueryException ('Cannot refresh documents ' );
146
131
}
147
- $ ids = [];
148
132
$ objects = [];
149
133
while ($ row = $ stmt ->fetch (PDO ::FETCH_OBJ )) {
150
- $ ids [] = (int ) $ row ->id ;
151
134
$ objects [] = new self ($ row );
152
- Common::$ cache ->set (
153
- 'bnetdocs-document- ' . $ row ->id , serialize ($ row ), 300
154
- );
155
135
}
156
136
$ stmt ->closeCursor ();
157
- Common::$ cache ->set ($ cache_key , implode (', ' , $ ids ), 300 );
158
137
return $ objects ;
159
138
} catch (PDOException $ e ) {
160
139
throw new QueryException ('Cannot refresh documents ' , $ e );
@@ -211,9 +190,6 @@ public static function getDocumentsByUserId($user_id) {
211
190
$ documents = [];
212
191
while ($ row = $ stmt ->fetch (PDO ::FETCH_OBJ )) {
213
192
$ documents [] = new self ($ row );
214
- Common::$ cache ->set (
215
- "bnetdocs-document- " . $ row ->id , serialize ($ row ), 300
216
- );
217
193
}
218
194
$ stmt ->closeCursor ();
219
195
return $ documents ;
@@ -292,19 +268,6 @@ protected static function normalize(StdClass &$data) {
292
268
}
293
269
294
270
public function refresh () {
295
- $ cache_key = "bnetdocs-document- " . $ this ->id ;
296
- $ cache_val = Common::$ cache ->get ($ cache_key );
297
- if ($ cache_val !== false ) {
298
- $ cache_val = unserialize ($ cache_val );
299
- $ this ->content = $ cache_val ->content ;
300
- $ this ->created_datetime = $ cache_val ->created_datetime ;
301
- $ this ->edited_count = $ cache_val ->edited_count ;
302
- $ this ->edited_datetime = $ cache_val ->edited_datetime ;
303
- $ this ->options_bitmask = $ cache_val ->options_bitmask ;
304
- $ this ->title = $ cache_val ->title ;
305
- $ this ->user_id = $ cache_val ->user_id ;
306
- return true ;
307
- }
308
271
if (!isset (Common::$ database )) {
309
272
Common::$ database = DatabaseDriver::getDatabaseObject ();
310
273
}
@@ -340,7 +303,6 @@ public function refresh() {
340
303
$ this ->options_bitmask = $ row ->options_bitmask ;
341
304
$ this ->title = $ row ->title ;
342
305
$ this ->user_id = $ row ->user_id ;
343
- Common::$ cache ->set ($ cache_key , serialize ($ row ), 300 );
344
306
return true ;
345
307
} catch (PDOException $ e ) {
346
308
throw new QueryException ("Cannot refresh document " , $ e );
@@ -380,21 +342,6 @@ public function save() {
380
342
throw new QueryException ("Cannot save document " );
381
343
}
382
344
$ stmt ->closeCursor ();
383
-
384
- $ object = new StdClass ();
385
- $ object ->content = $ this ->content ;
386
- $ object ->created_datetime = $ this ->created_datetime ;
387
- $ object ->edited_count = $ this ->edited_count ;
388
- $ object ->edited_datetime = $ this ->edited_datetime ;
389
- $ object ->id = $ this ->id ;
390
- $ object ->options_bitmask = $ this ->options_bitmask ;
391
- $ object ->title = $ this ->title ;
392
- $ object ->user_id = $ this ->user_id ;
393
-
394
- $ cache_key = "bnetdocs-document- " . $ this ->id ;
395
- Common::$ cache ->set ($ cache_key , serialize ($ object ), 300 );
396
- Common::$ cache ->delete ("bnetdocs-documents " );
397
-
398
345
return true ;
399
346
} catch (PDOException $ e ) {
400
347
throw new QueryException ("Cannot save document " , $ e );
0 commit comments