キャッシングの基本。 練習する

こんにちはハブラ

エントリー


以前の投稿「 キャッシングの基本」の発行後 どうやって? いつ? なんで? 練習について話す必要があることに気づきました。実際にこれを行います。 この投稿は前の投稿に似ていますが、実用的です。

PHP + MySQL + memcacheを使用します。


ちょっとした理論


-キャッシュキー。 キーを作成するための多くのオプションはありません。キャッシュを作成するときに、さまざまなパラメーターから得られたmd5を使用できます。または、プレフィックス+識別子を使用できます。 たとえば、キーnews_id_1234の下にニュースID 1234のキャッシュが保存され、キーnews_comments_1234の下にニュースID 1234のコメントが保存されます。
-配列のシリアル化。 使用するツールによっては、アレイをキャッシュする前に、シリアル化する必要がある場合があります。 memcacheの場合、この手順は不要です。

メインページ


メインページのキャッシュは完全に放棄し、各ブロックを個別にキャッシュすることにしました。
  1. // $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 */
  2. // $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 */
  3. // $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 */
  4. // $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 */
  5. // $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 */
  6. // $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 */
  7. // $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 */
  8. // $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 */
  9. // $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 */
  10. // $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 */
  11. // $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 */
  12. // $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 */
  13. // $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 */
  14. // $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 */
  15. // $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 */
  16. // $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 */
  17. // $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 */
  18. // $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 */
  19. // $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 */
  20. // $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 */
  21. // $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 */
  22. // $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 */
  23. // $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 */
  24. // $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 */
  25. // $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 */
  26. // $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 */
  27. // $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 */
  28. // $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 */
  29. // $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 */
  30. // $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 */
  31. // $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 */
  32. // $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 */
  33. // $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 */
  34. // $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 */
  35. // $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 */
  36. // $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 */
  37. // $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 */
  38. // $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 */
  39. // $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 */
  40. // $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 */
  41. // $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 */
  42. // $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 */
  43. // $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 */
  44. // $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 */
  45. // $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 */
  46. // $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 */
  47. // $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 */


ニュースを見る


ニュース自体のキャッシュ
  1. $ mem_news_id = $ memcache- > get 'news_id_' $ news_id ;
  2. if $ mem_news_id === false {
  3. $ result = mysql_query "SELECT * FROM news WHERE id =" $ news_id ;
  4. list $ news = mysql_fetch_array $ result ;
  5. $ news [ 'text' ] = very_hard_processing_to_html $ news [ 'text' ] ; //書式設定のニュースをHTMLの正規表現で解析します
  6. $ mem_news_id = $ news ;
  7. $ memcache- > set 'news_id_' $ news_id $ mem_news_id ;
  8. }
  9. / *
  10. 次に、ニュースを描画するために、データベースから受信したものを使用するのに使用したキャッシュから受信した$ mem_news_id配列を使用します
  11. * /


カウンターを見る
  1. $ mem_views = int $ memcache- > get 'news_id_views_' $ news_id ;
  2. mysql_query "UPDATE news SET views = views + 1 WHERE id =" $ news_id ; //データベース内のビューカウンターを更新します
  3. if mysql_affected_rows { //更新が成功した場合
  4. if $ mem_views
  5. $ memcache- > increment 'news_id_views_' $ news_id ; //キャッシュが存在する場合、値を増やします
  6. 他に
  7. $ memcache- > set 'news_id_views_' $ news_id 1 ; //キャッシュがない場合、ビューカウンターを作成します
  8. }
  9. $ mem_views ++;
  10. / *
  11. ビューの数が$ mem_views変数に追加されました
  12. * /


ニュースに関するコメント
  1. $ mem_comments = $ memcache- > get 'news_comments_' $ news_id ;
  2. if $ mem_comments === false {
  3. $ mem_comments = array ;
  4. $ i = 0 ;
  5. $ result = mysql_query "SELECT * FROMコメントWHERE news_id =" $ news_id "ORDER BY id DESC" ; //ニュースへのすべてのコメントを一度に取得
  6. while $ row = mysql_fetch_array $ result { //コメント付きの配列を置く
  7. $ row [ 'text' ] = very_hard_processing_to_html $ row [ 'text' ] ; //非常に重いコメントのフォーマット
  8. $ mem_comments [ $ i ] = $ row ;
  9. $ i ++;
  10. }
  11. $ memcache- > set 'news_comments_' $ news_id $ mem_comments ;
  12. }
  13. // html生成プロセス
  14. for $ i = $ page_offset $ c = count $ mem_comments ; $ i < $ c ; $ i ++ { //コメントのページナビゲーションを1行で簡単に調整できる
  15. $ comment = $ mem_comments [ $ i ] ;
  16. if $ comment != false { //コメントがある場合
  17. //ここで、変数$ comment内のコメントを処理し、htmlを収集します
  18. // ...
  19. }
  20. }

新しいメッセージを確認する


永久にキャッシュする方法は明らかなので、ユーザーアクティビティ(セッション)の期間中の短期キャッシュを検討してください。
  1. $ mem_new_messages = $ memcache- > get 'new_messages_' $ user_id ;
  2. if $ mem_new_messages === false {
  3. $ result = mysql_query "SELECT COUNT(*)AS new_messages FROM messages WHERE to_user =" $ user_id ; //データベースから新しいメッセージの数を取得します
  4. list $ mem_new_messages = mysql_fetch_array $ result ;
  5. $ live_time = 60 * 30 ; //(30分)
  6. $ memcache- > set 'new_messages_' $ user_id $ mem_new_messages false $ live_time ;
  7. }
  8. if $ _SESSION [ 'last_check' ] < time - 60 * 10 { //キャッシュの有効期間を延長する必要があるかどうかを確認する(10分ごと)
  9. $ _SESSION [ 'last_check' ] = time ;
  10. $ live_time = 60 * 30 ;
  11. $ memcache- > replace 'new_messages_' $ user_id $ mem_new_messages false $ live_time ;
  12. }


キャッシュの削除


必要に応じてキャッシュを削除することを忘れないでください! 上記のコードでは、どのような場合に削除する必要があるかは前の投稿で説明されています。 キャッシュの削除は非常に簡単です。
  1. $ memcache- > delete 'some_key' ;
  2. $ memcache- > delete 'news_id_' $ news_id ;


PS。 投稿の遅れをおIび申し上げます。 みなさん、ハッピーイースター!

Source: https://habr.com/ru/post/J89122/


All Articles