こんにちはハブラ
エントリー
以前の投稿「
キャッシングの基本」の発行後
。 どうやって? いつ? なんで? 練習について話す必要があることに気づきました。実際にこれを行います。 この投稿は前の投稿に似ていますが、実用的です。
PHP + MySQL + memcacheを使用します。
ちょっとした理論
-キャッシュキー。 キーを作成するための多くのオプションはありません。キャッシュを作成するときに、さまざまなパラメーターから得られたmd5を使用できます。または、プレフィックス+識別子を使用できます。 たとえば、キーnews_id_1234の下にニュースID 1234のキャッシュが保存され、キーnews_comments_1234の下にニュースID 1234のコメントが保存されます。
-配列のシリアル化。 使用するツールによっては、アレイをキャッシュする前に、シリアル化する必要がある場合があります。 memcacheの場合、この手順は不要です。
メインページ
メインページのキャッシュは完全に放棄し、各ブロックを個別にキャッシュすることにしました。
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
// $mem_block_last_news = $memcache -> get ( 'block_last_news' ) ; if ( $mem_block_last_news === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_news // ... } $memcache -> set ( 'block_last_news' , $mem_block_last_news ) ; } // $mem_block_popular = $memcache -> get ( 'block_popular' ) ; if ( $mem_block_popular === false ) { $time = time ( ) - 86400 * 7 ; // 7 $result = mysql_query ( "SELECT * FROM news WHERE added > " . $time . " ORDER BY views DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_popular // ... } $live_time = 86400 ; // () $memcache -> set ( 'block_popular' , $mem_block_popular , false , $live_time ) ; } // $mem_block_most_commented = $memcache -> get ( 'block_most_commented' ) ; if ( $mem_block_most_commented === false ) { $result = mysql_query ( "SELECT * FROM news ORDER BY comments DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_most_commented // ... } $live_time = 60 * 60 ; // () $memcache -> set ( 'block_most_commented' , $mem_block_most_commented , false , $live_time ) ; } // $mem_block_last_comments = $memcache -> get ( 'block_last_comments' ) ; if ( $mem_block_last_comments === false ) { $result = mysql_query ( "SELECT * FROM comments ORDER BY id DESC LIMIT 10" ) ; while ( $row = mysql_fetch_array ( $result ) ) { // html $mem_block_last_comments // ... } $live_time = 60 ; // () $memcache -> set ( 'block_last_comments' , $mem_block_last_comments , false , $live_time ) ; } /* $mem_block_last_news, $mem_block_popular, $mem_block_most_commented $mem_block_last_comments */
ニュースを見る
ニュース自体のキャッシュ
- $ mem_news_id = $ memcache- > get ( 'news_id_' 。 $ news_id ) ;
- if ( $ mem_news_id === false ) {
- $ result = mysql_query ( "SELECT * FROM news WHERE id =" 。 $ news_id ) ;
- list ( $ news ) = mysql_fetch_array ( $ result ) ;
- $ news [ 'text' ] = very_hard_processing_to_html ( $ news [ 'text' ] ) ; //書式設定のニュースをHTMLの正規表現で解析します
- $ mem_news_id = $ news ;
- $ memcache- > set ( 'news_id_' 。 $ news_id 、 $ mem_news_id ) ;
- }
- / *
- 次に、ニュースを描画するために、データベースから受信したものを使用するのに使用したキャッシュから受信した$ mem_news_id配列を使用します
- * /
カウンターを見る
- $ mem_views = ( int ) $ memcache- > get ( 'news_id_views_' 。 $ news_id ) ;
- mysql_query ( "UPDATE news SET views = views + 1 WHERE id =" 。 $ news_id ) ; //データベース内のビューカウンターを更新します
- if ( mysql_affected_rows ( ) ) { //更新が成功した場合
- if ( $ mem_views )
- $ memcache- > increment ( 'news_id_views_' 。 $ news_id ) ; //キャッシュが存在する場合、値を増やします
- 他に
- $ memcache- > set ( 'news_id_views_' 。 $ news_id 、 1 ) ; //キャッシュがない場合、ビューカウンターを作成します
- }
- $ mem_views ++;
- / *
- ビューの数が$ mem_views変数に追加されました
- * /
ニュースに関するコメント
- $ mem_comments = $ memcache- > get ( 'news_comments_' 。 $ news_id ) ;
- if ( $ mem_comments === false ) {
- $ mem_comments = array ( ) ;
- $ i = 0 ;
- $ result = mysql_query ( "SELECT * FROMコメントWHERE news_id =" 。 $ news_id 。 "ORDER BY id DESC" ) ; //ニュースへのすべてのコメントを一度に取得
- while ( $ row = mysql_fetch_array ( $ result ) ) { //コメント付きの配列を置く
- $ row [ 'text' ] = very_hard_processing_to_html ( $ row [ 'text' ] ) ; //非常に重いコメントのフォーマット
- $ mem_comments [ $ i ] = $ row ;
- $ i ++;
- }
- $ memcache- > set ( 'news_comments_' 。 $ news_id 、 $ mem_comments ) ;
- }
- // html生成プロセス
- for ( $ i = $ page_offset 、 $ c = count ( $ mem_comments ) ; $ i < $ c ; $ i ++ ) { //コメントのページナビゲーションを1行で簡単に調整できる
- $ comment = $ mem_comments [ $ i ] ;
- if ( $ comment != false ) { //コメントがある場合
- //ここで、変数$ comment内のコメントを処理し、htmlを収集します
- // ...
- }
- }
新しいメッセージを確認する
永久にキャッシュする方法は明らかなので、ユーザーアクティビティ(セッション)の期間中の短期キャッシュを検討してください。
- $ mem_new_messages = $ memcache- > get ( 'new_messages_' 。 $ user_id ) ;
- if ( $ mem_new_messages === false ) {
- $ result = mysql_query ( "SELECT COUNT(*)AS new_messages FROM messages WHERE to_user =" 。 $ user_id ) ; //データベースから新しいメッセージの数を取得します
- list ( $ mem_new_messages ) = mysql_fetch_array ( $ result ) ;
- $ live_time = 60 * 30 ; //(30分)
- $ memcache- > set ( 'new_messages_' 。 $ user_id 、 $ mem_new_messages 、 false 、 $ live_time ) ;
- }
- if ( $ _SESSION [ 'last_check' ] < time ( ) - 60 * 10 ) { //キャッシュの有効期間を延長する必要があるかどうかを確認する(10分ごと)
- $ _SESSION [ 'last_check' ] = time ( ) ;
- $ live_time = 60 * 30 ;
- $ memcache- > replace ( 'new_messages_' 。 $ user_id 、 $ mem_new_messages 、 false 、 $ live_time ) ;
- }
キャッシュの削除
必要に応じてキャッシュを削除することを忘れないでください! 上記のコードでは、どのような場合に削除する必要があるかは前の投稿で説明されています。 キャッシュの削除は非常に簡単です。
- $ memcache- > delete ( 'some_key' ) ;
- $ memcache- > delete ( 'news_id_' 。 $ news_id ) ;
PS。 投稿の遅れをおIび申し上げます。 みなさん、ハッピーイースター!