我喜歡memcached如何工作。您可以使用它存儲數據塊以提高網站性能。當你想檢索一些數據時,你首先檢查它是否在memcached中,如果是的話,那麼你檢索它,否則你檢查你的數據庫/文件系統等。何時使用memcached
我只是不知道如何/何時使用它?什麼會是一個好機會?
我有以下表格:
作者:
ID的用戶名郵箱密碼鹽 email_salt email_verified IP_ADDRESS
Author_threads:
的thread_id,AUTHOR_ID
主題:
ID,標題,內容,創造
標籤:
ID,名稱
Thread_tags:
tad_id,THREAD_ID
我想選擇最新的30個線程,它們的作者和他們所有的標籤。這是在SQL語句中使用:
SELECT thread.title, thread.id as thread_id,
thread.content, author.username, author.id as author_id,
GROUP_CONCAT(DISTINCT tag.name ORDER BY tag.name DESC SEPARATOR ',') AS tags
FROM thread
JOIN thread_tags ON thread.id = thread_tags.thread_id
JOIN tag ON thread_tags.tag_id = tag.id
JOIN author_threads ON thread.id = author_threads.thread_id
JOIN author ON author_threads.author_id = author.id
GROUP BY thread.id DESC
LIMIT 0, 30
這是我使用PHP:
function get_latest_threads($link, $start)
{
$start = minimal_int($start);
$threads = sql_select($link, "SELECT thread.title, thread.id as thread_id,
thread.content, author.username, author.id as author_id,
GROUP_CONCAT(DISTINCT tag.name ORDER BY tag.name DESC SEPARATOR ',') AS tags
FROM thread
JOIN thread_tags ON thread.id = thread_tags.thread_id
JOIN tag ON thread_tags.tag_id = tag.id
JOIN author_threads ON thread.id = author_threads.thread_id
JOIN author ON author_threads.author_id = author.id
GROUP BY thread.id DESC
LIMIT $start, 30" # I only want to retrieve 30 records each time
);
return $threads;
}
在哪裏/如何將memcached的是使用嗎?
非常感謝使用代碼分析器的想法。 – kta 2015-01-22 23:18:39