longer cache timings, with better invalidation
This commit is contained in:
		
							parent
							
								
									6c4fd0d14d
								
							
						
					
					
						commit
						8dfeb7cda3
					
				| @ -52,7 +52,7 @@ class User { | |||||||
| 				$query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess"; | 				$query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess"; | ||||||
| 			} | 			} | ||||||
| 			$row = $database->get_row($query, array("name"=>$name, "ip"=>get_session_ip($config), "sess"=>$session)); | 			$row = $database->get_row($query, array("name"=>$name, "ip"=>get_session_ip($config), "sess"=>$session)); | ||||||
| 			$database->cache->set("user-session-$name-$session", $row, 300); | 			$database->cache->set("user-session-$name-$session", $row, 600); | ||||||
| 		} | 		} | ||||||
| 		return is_null($row) ? null : new User($row); | 		return is_null($row) ? null : new User($row); | ||||||
| 	} | 	} | ||||||
| @ -65,7 +65,7 @@ class User { | |||||||
| 			if($cached) return new User($cached); | 			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); | 		if($id === 1) $database->cache->set('user-id:'.$id, $row, 600); | ||||||
| 		return is_null($row) ? null : new User($row); | 		return is_null($row) ? null : new User($row); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ class Blocks extends Extension { | |||||||
| 		$blocks = $database->cache->get("blocks"); | 		$blocks = $database->cache->get("blocks"); | ||||||
| 		if($blocks === false) { | 		if($blocks === false) { | ||||||
| 			$blocks = $database->get_all("SELECT * FROM blocks"); | 			$blocks = $database->get_all("SELECT * FROM blocks"); | ||||||
| 			$database->cache->set("blocks", $blocks, 300); | 			$database->cache->set("blocks", $blocks, 600); | ||||||
| 		} | 		} | ||||||
| 		foreach($blocks as $block) { | 		foreach($blocks as $block) { | ||||||
| 			if(fnmatch($block['pages'], implode("/", $event->args))) { | 			if(fnmatch($block['pages'], implode("/", $event->args))) { | ||||||
|  | |||||||
| @ -66,7 +66,7 @@ class Featured extends Extension { | |||||||
| 				if($image) { // make sure the object is fully populated before saving
 | 				if($image) { // make sure the object is fully populated before saving
 | ||||||
| 					$image->get_tag_array(); | 					$image->get_tag_array(); | ||||||
| 				} | 				} | ||||||
| 				$database->cache->set("featured_image_object-$fid", $image, 60); | 				$database->cache->set("featured_image_object-$fid", $image, 600); | ||||||
| 			} | 			} | ||||||
| 			if(!is_null($image)) { | 			if(!is_null($image)) { | ||||||
| 				if(class_exists("Ratings")) { | 				if(class_exists("Ratings")) { | ||||||
|  | |||||||
| @ -198,7 +198,7 @@ class PrivMsg extends Extension { | |||||||
| 					WHERE to_id = :to_id | 					WHERE to_id = :to_id | ||||||
| 					AND is_read = :is_read | 					AND is_read = :is_read | ||||||
| 			", array("to_id" => $user->id, "is_read" => "N"));
 | 			", array("to_id" => $user->id, "is_read" => "N"));
 | ||||||
| 			$database->cache->set("pm-count-{$user->id}", $count, 60); | 			$database->cache->set("pm-count-{$user->id}", $count, 600); | ||||||
| 		} | 		} | ||||||
| 		return $count; | 		return $count; | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -72,11 +72,13 @@ class ReportImage extends Extension { | |||||||
| 				"INSERT INTO image_reports(image_id, reporter_id, reason)
 | 				"INSERT INTO image_reports(image_id, reporter_id, reason)
 | ||||||
| 				VALUES (?, ?, ?)",
 | 				VALUES (?, ?, ?)",
 | ||||||
| 				array($event->image_id, $event->reporter_id, $event->reason)); | 				array($event->image_id, $event->reporter_id, $event->reason)); | ||||||
|  | 		$database->cache->delete("image-report-count"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public function onRemoveReportedImage(RemoveReportedImageEvent $event) { | 	public function onRemoveReportedImage(RemoveReportedImageEvent $event) { | ||||||
| 		global $database; | 		global $database; | ||||||
| 		$database->Execute("DELETE FROM image_reports WHERE id = ?", array($event->id)); | 		$database->Execute("DELETE FROM image_reports WHERE id = ?", array($event->id)); | ||||||
|  | 		$database->cache->delete("image-report-count"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public function onDisplayingImage(DisplayingImageEvent $event) { | 	public function onDisplayingImage(DisplayingImageEvent $event) { | ||||||
| @ -99,6 +101,7 @@ class ReportImage extends Extension { | |||||||
| 	public function onImageDeletion(ImageDeletionEvent $event) { | 	public function onImageDeletion(ImageDeletionEvent $event) { | ||||||
| 		global $database; | 		global $database; | ||||||
| 		$database->Execute("DELETE FROM image_reports WHERE image_id = ?", array($event->image->id)); | 		$database->Execute("DELETE FROM image_reports WHERE image_id = ?", array($event->image->id)); | ||||||
|  | 		$database->cache->delete("image-report-count"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	protected function install() { | 	protected function install() { | ||||||
| @ -156,7 +159,7 @@ class ReportImage extends Extension { | |||||||
| 		$count = $database->cache->get("image-report-count"); | 		$count = $database->cache->get("image-report-count"); | ||||||
| 		if(is_null($count) || $count === false) { | 		if(is_null($count) || $count === false) { | ||||||
| 			$count = $database->get_one("SELECT count(*) FROM image_reports"); | 			$count = $database->get_one("SELECT count(*) FROM image_reports"); | ||||||
| 			$database->cache->set("image-report-count", $count, 60); | 			$database->cache->set("image-report-count", $count, 600); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return $count; | 		return $count; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user