Skip to content

Commit 2302413

Browse files
committed
Rip out memcache from Document class
1 parent c520b9a commit 2302413

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

src/libraries/Document.php

-53
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public static function create(
7878
$stmt->bindParam(":content", $content, PDO::PARAM_STR);
7979
$successful = $stmt->execute();
8080
$stmt->closeCursor();
81-
if ($successful) Common::$cache->delete("bnetdocs-documents");
8281
} catch (PDOException $e) {
8382
throw new QueryException("Cannot create document", $e);
8483
} finally {
@@ -99,10 +98,6 @@ public static function delete($id) {
9998
$stmt->bindParam(":id", $id, PDO::PARAM_INT);
10099
$successful = $stmt->execute();
101100
$stmt->closeCursor();
102-
if ($successful) {
103-
Common::$cache->delete("bnetdocs-document-" . (int) $id);
104-
Common::$cache->delete("bnetdocs-documents");
105-
}
106101
} catch (PDOException $e) {
107102
throw new QueryException("Cannot delete document", $e);
108103
} finally {
@@ -112,16 +107,6 @@ public static function delete($id) {
112107
}
113108

114109
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-
}
125110
if (!isset(Common::$database)) {
126111
Common::$database = DatabaseDriver::getDatabaseObject();
127112
}
@@ -144,17 +129,11 @@ public static function getAllDocuments( $order = null ) {
144129
if (!$stmt->execute()) {
145130
throw new QueryException('Cannot refresh documents');
146131
}
147-
$ids = [];
148132
$objects = [];
149133
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
150-
$ids[] = (int) $row->id;
151134
$objects[] = new self($row);
152-
Common::$cache->set(
153-
'bnetdocs-document-' . $row->id, serialize($row), 300
154-
);
155135
}
156136
$stmt->closeCursor();
157-
Common::$cache->set($cache_key, implode(',', $ids), 300);
158137
return $objects;
159138
} catch (PDOException $e) {
160139
throw new QueryException('Cannot refresh documents', $e);
@@ -211,9 +190,6 @@ public static function getDocumentsByUserId($user_id) {
211190
$documents = [];
212191
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
213192
$documents[] = new self($row);
214-
Common::$cache->set(
215-
"bnetdocs-document-" . $row->id, serialize($row), 300
216-
);
217193
}
218194
$stmt->closeCursor();
219195
return $documents;
@@ -292,19 +268,6 @@ protected static function normalize(StdClass &$data) {
292268
}
293269

294270
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-
}
308271
if (!isset(Common::$database)) {
309272
Common::$database = DatabaseDriver::getDatabaseObject();
310273
}
@@ -340,7 +303,6 @@ public function refresh() {
340303
$this->options_bitmask = $row->options_bitmask;
341304
$this->title = $row->title;
342305
$this->user_id = $row->user_id;
343-
Common::$cache->set($cache_key, serialize($row), 300);
344306
return true;
345307
} catch (PDOException $e) {
346308
throw new QueryException("Cannot refresh document", $e);
@@ -380,21 +342,6 @@ public function save() {
380342
throw new QueryException("Cannot save document");
381343
}
382344
$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-
398345
return true;
399346
} catch (PDOException $e) {
400347
throw new QueryException("Cannot save document", $e);

0 commit comments

Comments
 (0)