cache anon, it gets looked up a lot
This commit is contained in:
parent
811f9e0f66
commit
cd86859f08
@ -53,7 +53,12 @@ class User {
|
|||||||
public static function by_id($id) {
|
public static function by_id($id) {
|
||||||
assert(is_numeric($id));
|
assert(is_numeric($id));
|
||||||
global $database;
|
global $database;
|
||||||
|
if($id == 1) {
|
||||||
|
$cached = $database->cache->get("user-id:$id");
|
||||||
|
if($cached) return new User($cached);
|
||||||
|
}
|
||||||
$row = $database->get_row("SELECT * FROM users WHERE id = :id", array("id"=>$id));
|
$row = $database->get_row("SELECT * FROM users WHERE id = :id", array("id"=>$id));
|
||||||
|
if($id == 1) $database->cache->set("user-id:$id", $row, 300);
|
||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user