Skip to content

Commit

Permalink
Remove cache from ServerType class
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Mar 3, 2021
1 parent 97d4a5f commit 679cc98
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/libraries/ServerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ public function __construct($data) {
}

public static function getAllServerTypes() {
$cache_key = "bnetdocs-servertypes";
$cache_val = Common::$cache->get($cache_key);
if ($cache_val !== false && !empty($cache_val)) {
$ids = explode(",", $cache_val);
$objects = [];
foreach ($ids as $id) {
$objects[] = new self($id);
}
return $objects;
}
if (!isset(Common::$database)) {
Common::$database = DatabaseDriver::getDatabaseObject();
}
Expand All @@ -59,17 +49,11 @@ public static function getAllServerTypes() {
if (!$stmt->execute()) {
throw new QueryException("Cannot refresh server types");
}
$ids = [];
$objects = [];
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
$ids[] = (int) $row->id;
$objects[] = new self($row);
Common::$cache->set(
"bnetdocs-servertype-" . $row->id, serialize($row), 300
);
}
$stmt->closeCursor();
Common::$cache->set($cache_key, implode(",", $ids), 300);
return $objects;
} catch (PDOException $e) {
throw new QueryException("Cannot refresh server types", $e);
Expand Down Expand Up @@ -100,13 +84,6 @@ protected static function normalize(StdClass &$data) {
}

public function refresh() {
$cache_key = "bnetdocs-servertype-" . $this->id;
$cache_val = Common::$cache->get($cache_key);
if ($cache_val !== false) {
$cache_val = unserialize($cache_val);
$this->label = $cache_val->label;
return true;
}
if (!isset(Common::$database)) {
Common::$database = DatabaseDriver::getDatabaseObject();
}
Expand All @@ -129,7 +106,6 @@ public function refresh() {
$stmt->closeCursor();
self::normalize($row);
$this->label = $row->label;
Common::$cache->set($cache_key, serialize($row), 300);
return true;
} catch (PDOException $e) {
throw new QueryException("Cannot refresh server type", $e);
Expand Down

0 comments on commit 679cc98

Please sign in to comment.