From 066474c5c53ec0682550fa9434a577f9624df6fe Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 19 Jan 2009 10:27:53 -0800 Subject: [PATCH] use caching for image tags --- core/imageboard.pack.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 3b743802..3c014a11 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -144,6 +144,9 @@ class Image { } public function get_tag_array() { + $cached = $this->database->cache_get("image-{$this->id}-tags"); + if($cached) return $cached; + if(!isset($this->tag_array)) { $this->tag_array = Array(); $row = $this->database->Execute("SELECT tag FROM image_tags JOIN tags ON image_tags.tag_id = tags.id WHERE image_id=? ORDER BY tag", array($this->id)); @@ -152,6 +155,8 @@ class Image { $row->MoveNext(); } } + + $this->database->cache_set("image-{$this->id}-tags", $this->tag_array); return $this->tag_array; } @@ -261,6 +266,8 @@ class Image { "UPDATE tags SET count = count + 1 WHERE tag = ?", array($tag)); } + + $this->database->cache_delete("image-{$this->id}-tags"); }