cache anon, it gets looked up a lot
This commit is contained in:
parent
811f9e0f66
commit
cd86859f08
1 changed files with 5 additions and 0 deletions
|
@ -53,7 +53,12 @@ class User {
|
|||
public static function by_id($id) {
|
||||
assert(is_numeric($id));
|
||||
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));
|
||||
if($id == 1) $database->cache->set("user-id:$id", $row, 300);
|
||||
return is_null($row) ? null : new User($row);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue