Issue 152: Add cache for project info

master
Nathan Adams 2016-04-23 15:28:24 -05:00
parent 3f699e0afd
commit 490ce3dd08
3 changed files with 24 additions and 5 deletions

View File

@ -108,6 +108,7 @@ class IDF_Conf extends Pluf_Model
$conf->vdesc = $value;
$conf->create();
$this->initCache();
$this->_project->invalidateConfCache();
}
function getVal($key, $default='')

View File

@ -161,6 +161,14 @@ class IDF_Project extends Pluf_Model
);
}
public function invalidateConfCache() {
$cache = Pluf_Cache::factory();
$keys = $this->getConf()->getKeys();
foreach($keys as $key) {
$cache->set("confCache" . $this->id . $key, null);
}
}
/**
* String representation of the abstract.
@ -670,7 +678,14 @@ GROUP BY uid";
return parent::__get($key);
}
catch (Exception $e) {
return $this->getConf()->getVal($key);
$cache = Pluf_Cache::factory();
if (null === ($confCache = $cache->get("confCache" . $this->id . $key, null))) {
$confCache = $this->getConf()->getVal($key);
$cache->set("confCache" . $this->id . $key, $confCache);
return $confCache;
} else {
return $confCache;
}
}
}

View File

@ -10,14 +10,17 @@
{/if}{if $customForgePageEnabled}
<li><a href="{url 'IDF_Views::index'}">{trans 'Home'}</a></li>
{/if}<li id="project-list"><a href="{url 'IDF_Views::listProjects'}">{trans 'Project List'} &#x25be;</a>
{if $allProjects.count() != 0}
{if $allProjects.count() != 0}
<ul class="prjlistclass">
<li id="searchkeep"><input size="15" type="text" id="prjname" name="prjname" placeholder="Project Name..." /></li>
{foreach $allProjects as $p}
<li class="projectitem"><a href="{url 'IDF_Views_Project::home', array($p.shortname)}"><img src="{media '/idf/img/no_logo.png'}" data-logo="{$p.logo}" class="logo" data-src="{url 'IDF_Views_Project::logo64', array($p.shortname)}" alt="{trans 'Project logo'}" />{if $p.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}</a></li>
{/foreach}</ul>
{/if}</li>{if $isAdmin}<li><a href="{url 'IDF_Views_Admin::forge'}">{trans 'Forge Management'} {if $pendingProjects > 0}({$pendingProjects}){/if}</a></li>{/if}<li>
<li class="projectitem"><a href="{url 'IDF_Views_Project::home', array($p.shortname)}"><img src="{media '/idf/img/no_logo.png'}" data-logo="{$p.logo}" class="logo" data-src="{url 'IDF_Views_Project::logo64', array($p.shortname)}" alt="{trans 'Project logo'}" />{if $p.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}</a></li>
{/foreach}
</ul>
{/if}
</li>{if $isAdmin}<li><a href="{url 'IDF_Views_Admin::forge'}">{trans 'Forge Management'} {if $pendingProjects > 0}({$pendingProjects}){/if}</a></li>{/if}<li>
<a href="{url 'IDF_Views::faq'}" title="{trans 'Help and accessibility features'}">{trans 'Help'}</a></li>
</ul>