Skip to content

Commit eb3ae8f

Browse files
committed
Remove memcache from Comment class
1 parent 22b4a53 commit eb3ae8f

File tree

1 file changed

+0
-58
lines changed

1 file changed

+0
-58
lines changed

src/libraries/Comment.php

-58
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ public static function create($parent_type, $parent_id, $user_id, $content) {
8686
} catch (PDOException $e) {
8787
throw new QueryException("Cannot create comment", $e);
8888
} finally {
89-
$ck = "bnetdocs-comment-" . $parent_type . "-" . $parent_id;
90-
Common::$cache->delete($ck);
9189
return $successful;
9290
}
9391
}
@@ -104,12 +102,6 @@ public static function delete($id, $parent_type, $parent_id) {
104102
$stmt->bindParam(":id", $id, PDO::PARAM_INT);
105103
$successful = $stmt->execute();
106104
$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-
}
113105
} catch (PDOException $e) {
114106
throw new QueryException("Cannot delete comment", $e);
115107
} finally {
@@ -118,16 +110,6 @@ public static function delete($id, $parent_type, $parent_id) {
118110
}
119111

120112
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-
}
131113
if (!isset(Common::$database)) {
132114
Common::$database = DatabaseDriver::getDatabaseObject();
133115
}
@@ -156,17 +138,11 @@ public static function getAll($parent_type, $parent_id) {
156138
if (!$stmt->execute()) {
157139
throw new QueryException("Cannot refresh comment");
158140
}
159-
$ids = [];
160141
$objects = [];
161142
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
162-
$ids[] = (int) $row->id;
163143
$objects[] = new self($row);
164-
Common::$cache->set(
165-
"bnetdocs-comment-" . $row->id, serialize($row), self::CACHE_TTL
166-
);
167144
}
168145
$stmt->closeCursor();
169-
Common::$cache->set($ck, implode(",", $ids), self::CACHE_TTL);
170146
return $objects;
171147
} catch (PDOException $e) {
172148
throw new QueryException("Cannot refresh comment", $e);
@@ -267,20 +243,6 @@ protected static function normalize(StdClass &$data) {
267243
}
268244

269245
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-
}
284246
if (!isset(Common::$database)) {
285247
Common::$database = DatabaseDriver::getDatabaseObject();
286248
}
@@ -316,7 +278,6 @@ public function refresh() {
316278
$this->parent_id = $row->parent_id;
317279
$this->parent_type = $row->parent_type;
318280
$this->user_id = $row->user_id;
319-
Common::$cache->set($ck, serialize($row), self::CACHE_TTL);
320281
return true;
321282
} catch (PDOException $e) {
322283
throw new QueryException("Cannot refresh comment", $e);
@@ -356,25 +317,6 @@ public function save() {
356317
throw new QueryException( 'Cannot save comment' );
357318
}
358319
$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-
378320
return true;
379321
} catch ( PDOException $e ) {
380322
throw new QueryException( 'Cannot save comment', $e );

0 commit comments

Comments
 (0)