Skip to content

Commit 22b4a53

Browse files
committed
Remove memcache from Server class
1 parent 35366f7 commit 22b4a53

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

src/libraries/Server.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ public function getAddress() {
6666
}
6767

6868
public static function getAllServers() {
69-
$cache_key = "bnetdocs-servers";
70-
$cache_val = Common::$cache->get($cache_key);
71-
if ($cache_val !== false && !empty($cache_val)) {
72-
$ids = explode(",", $cache_val);
73-
$objects = [];
74-
foreach ($ids as $id) {
75-
$objects[] = new self($id);
76-
}
77-
return $objects;
78-
}
7969
if (!isset(Common::$database)) {
8070
Common::$database = DatabaseDriver::getDatabaseObject();
8171
}
@@ -102,17 +92,11 @@ public static function getAllServers() {
10292
if (!$stmt->execute()) {
10393
throw new QueryException("Cannot refresh servers");
10494
}
105-
$ids = [];
10695
$objects = [];
10796
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
108-
$ids[] = (int) $row->id;
10997
$objects[] = new self($row);
110-
Common::$cache->set(
111-
"bnetdocs-server-" . $row->id, serialize($row), 300
112-
);
11398
}
11499
$stmt->closeCursor();
115-
Common::$cache->set($cache_key, implode(",", $ids), 300);
116100
return $objects;
117101
} catch (PDOException $e) {
118102
throw new QueryException("Cannot refresh servers", $e);
@@ -174,14 +158,9 @@ public static function getServersByUserId($user_id) {
174158
if (!$stmt->execute()) {
175159
throw new QueryException('Cannot query servers by user id');
176160
}
177-
$ids = [];
178161
$objects = [];
179162
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
180-
$ids[] = (int) $row->id;
181163
$objects[] = new self($row);
182-
Common::$cache->set(
183-
'bnetdocs-server-' . $row->id, serialize($row), 300
184-
);
185164
}
186165
$stmt->closeCursor();
187166
return $objects;
@@ -292,20 +271,6 @@ protected static function normalize(StdClass &$data) {
292271
}
293272

294273
public function refresh() {
295-
$cache_key = "bnetdocs-server-" . $this->id;
296-
$cache_val = Common::$cache->get($cache_key);
297-
if ($cache_val !== false) {
298-
$cache_val = unserialize($cache_val);
299-
$this->address = $cache_val->address;
300-
$this->created_datetime = $cache_val->created_datetime;
301-
$this->label = $cache_val->label;
302-
$this->port = $cache_val->port;
303-
$this->status_bitmask = $cache_val->status_bitmask;
304-
$this->type_id = $cache_val->type_id;
305-
$this->updated_datetime = $cache_val->updated_datetime;
306-
$this->user_id = $cache_val->user_id;
307-
return true;
308-
}
309274
if (!isset(Common::$database)) {
310275
Common::$database = DatabaseDriver::getDatabaseObject();
311276
}
@@ -342,7 +307,6 @@ public function refresh() {
342307
$this->type_id = $row->type_id;
343308
$this->updated_datetime = $row->updated_datetime;
344309
$this->user_id = $row->user_id;
345-
Common::$cache->set($cache_key, serialize($row), 300);
346310
return true;
347311
} catch (PDOException $e) {
348312
throw new QueryException("Cannot refresh server", $e);
@@ -396,22 +360,6 @@ public function save() {
396360
throw new QueryException( 'Cannot save server' );
397361
}
398362
$stmt->closeCursor();
399-
400-
$object = new StdClass();
401-
$object->address = $this->address;
402-
$object->created_datetime = $this->created_datetime;
403-
$object->id = $this->id;
404-
$object->label = $this->label;
405-
$object->port = $this->port;
406-
$object->status_bitmask = $this->status_bitmask;
407-
$object->type_id = $this->type_id;
408-
$object->updated_datetime = $this->updated_datetime;
409-
$object->user_id = $this->user_id;
410-
411-
$cache_key = 'bnetdocs-server-' . $this->id;
412-
Common::$cache->set( $cache_key, serialize( $object ), 300 );
413-
Common::$cache->delete( 'bnetdocs-servers' );
414-
415363
return true;
416364

417365
} catch ( PDOException $e ) {

0 commit comments

Comments
 (0)