OSDN Git Service

Homeキャッシュをページ単位で行うに変更
authorCake <cake_67@users.sourceforge.jp>
Sat, 25 Dec 2010 06:44:10 +0000 (15:44 +0900)
committerCake <cake_67@users.sourceforge.jp>
Sat, 25 Dec 2010 06:44:10 +0000 (15:44 +0900)
app/models/app_model.php
app/models/character.php
app/models/user.php
app/views/elements/home_right.ctp
app/views/elements/user_index.ctp [new file with mode: 0644]
app/views/users/index.ctp

index acd738c..4fdec29 100644 (file)
@@ -443,11 +443,11 @@ class AppModel extends Model {
 
        /* キャッシュ削除 */
        // ホーム関連
-       function deleteCacheHome()
+       function deleteCacheHome($user_id = null)
        {
                $this->deleteCacheLastCharacters();
                $this->deleteCacheAnonymousHome();
-               $this->deleteCacheMyData();
+               $this->deleteCacheMyData($user_id);
        }
 
        // 最近更新されたキャラクター
@@ -459,21 +459,22 @@ class AppModel extends Model {
        // 未ログインホーム
        function deleteCacheAnonymousHome()
        {
-               @unlink(CACHE.'views'.DS.'element__home_right');
+               @unlink(CACHE.'views'.DS.'element_0_user_index');
        }
 
        // 自セッション関連
-       function deleteCacheMyData()
+       function deleteCacheMyData($user_id = null)
        {
                $Session = CorePlus::set_behavoir('Session');
 
+               if (!empty($user_id)) {
+                       @unlink(CACHE.'views'.DS.'element_'.$user_id.'_user_index');
+               }
+
                if (!$Session->id()) {
                        return false;
                }
-
                @unlink(CACHE.'views'.DS.'element_'.$Session->id().'_character_picture_table');
-               @unlink(CACHE.'views'.DS.'element_'.$Session->id().'_home_left');
-
                @unlink(CACHE.'views'.DS.'element_'.$Session->id().'_character_index');
        }
 
@@ -522,6 +523,7 @@ class AppModel extends Model {
                if (!empty($user_id)) {
                        clearCache('_users_view_'.$user_id);
 
+                       @unlink(CACHE.'views'.DS.'element_'.$user_id.'user_index');
                        @unlink(CACHE.'views'.DS.'element_'.$user_id.'_character_picture_table');
                        @unlink(CACHE.'views'.DS.'element_'.$user_id.'_character_view');
                }
index a2b6729..d24a0c8 100644 (file)
@@ -474,14 +474,14 @@ class Character extends AppModel {
                // 自セッション関連
                $this->deleteCacheMyData();
 
-               // Home
-               $this->deleteCacheHome();
-
                $this->deleteCacheCharacter($this->id, false);
 
                if (isset($this->data['clearCache'])) {
+                       $this->deleteCacheHome($this->data['clearCache']['user_id']);
                        $this->deleteCacheUser($this->data['clearCache']['user_id']);
                        $this->deleteCacheSystem($this->data['clearCache']['system_id'], false); // System一覧の更新遅れを修正する場合true
+               } else {
+                       $this->deleteCacheHome();
                }
 
                // ProfileArchive
index df5627b..0e0b2ad 100644 (file)
@@ -220,7 +220,7 @@ class User extends AppModel {
        function deleteCache4User()
        {
                // 自セッション関連
-               $this->deleteCacheMyData();
+               $this->deleteCacheMyData($this->id);
 
                $this->deleteCacheHome();
                $this->deleteCacheUser($this->id);
index 0ffe8a7..efd950d 100644 (file)
@@ -22,20 +22,24 @@ if (isset($news)) {
 <?php if (isset($target_user_characters) && !empty($target_user_characters) && isset($target_user)): ?>
 <!-- All User Characters -->
 <?php
+       $rightCache = array(
+               'time' => time() + Configure::read('Cache.expire'),
+       );
        if ($owner) {
                $more_url = array(
                        'controller' => 'characters', 
                        'action' => 'mycharacter',
                );
-               $key = $session->id();
+               $rightCache = '';
        } else {
                $more_url = array(
                        'controller' => 'characters', 
                        'action' => 'index',
                        $target_user['User']['id'],
                );
-               $key = null;
-               $key .= "_". $target_user['User']['id'];
+               $rightCache = array_merge($rightCache, array(
+                       'key' => "_". $target_user['User']['id'],
+               ));
        }
 
        echo $this->element('character_picture_table', array(
@@ -49,10 +53,7 @@ if (isset($news)) {
                'viewPublic' => true,
                'more_url' => $more_url,
                'other_url' => $add_url,
-               'cache' => array(
-                       'time' => time() + Configure::read('Cache.expire'),
-                       'key' => $key,
-               )
+               'cache' => $rightCache
        ));
 ?>
 <?php endif; ?>
diff --git a/app/views/elements/user_index.ctp b/app/views/elements/user_index.ctp
new file mode 100644 (file)
index 0000000..d237a71
--- /dev/null
@@ -0,0 +1,35 @@
+<?php if (!empty($characters)): ?>
+
+<?php
+if (isset($news)) {
+       echo $this->element('information', array(
+               'news' => $news,
+               'cache' => time() + Configure::read('Cache.expireLong'),
+       ));
+}
+?>
+
+<?php echo $characters ?>
+<?php else: ?>
+<div id="home" class="layout2colums users view">
+<?php 
+
+if ($user['User']['id']) {
+       $key = $session->id();
+
+       echo $this->element('home_left', array(
+               'target_user' => $user,
+               'owner' => true,
+       ));
+}
+
+echo $this->element('home_right', array(
+       'target_user' => $user,
+       'target_user_characters' => $target_user_characters,
+       'owner' => true,
+       'public_characters' => $public_characters,
+));
+
+?>
+</div>
+<?php endif; ?>
\ No newline at end of file
index ff55906..b10a7ca 100644 (file)
@@ -1,40 +1,18 @@
-<?php if (!empty($characters)): ?>
-
-<?php
-if (isset($news)) {
-       echo $this->element('information', array(
-               'news' => $news,
-               'cache' => time() + Configure::read('Cache.expireLong'),
-       ));
-}
-?>
-
-<?php echo $characters ?>
-<?php else: ?>
-<div id="home" class="layout2colums users view">
 <?php 
-$key = null;
-
-if ($user['User']['id']) {
-       $key = $session->id();
-
-       echo $this->element('home_left', array(
-               'target_user' => $user,
-               'owner' => true,
-               'cache' => array(
-                       'time' => time() + Configure::read('Cache.expire'),
-                       'key' => $key,
-               ) 
-       ));
+$cacheSet['time'] = time() + Configure::read('Cache.expireShort');
+if (empty($character) || $user['User']['id']) {
+       $cacheSet['key'] = $user['User']['id'];
+} else {
+       $cacheSet['key'] = null;
 }
 
-echo $this->element('home_right', array(
-       'target_user' => $user,
-       'target_user_characters' => $target_user_characters,
-       'owner' => true,
-       'public_characters' => $public_characters,
-));
+echo $this->element(
+       'user_index',
+       array(
+               'user' => $user,
+               'news' => $news,
+               'characters' => $characters,
+               'cache' => $cacheSet,
+       )
+);
 
-?>
-</div>
-<?php endif; ?>
\ No newline at end of file