[pLog-svn] r2046 - in plog/branches/plog-1.1-ben/class:
action/admin dao
ork at devel.plogworld.net
ork at devel.plogworld.net
Sun May 22 16:57:59 GMT 2005
Author: ork
Date: 2005-05-22 16:57:59 +0000 (Sun, 22 May 2005)
New Revision: 2046
Modified:
plog/branches/plog-1.1-ben/class/action/admin/admineditlinkaction.class.php
plog/branches/plog-1.1-ben/class/dao/mylinks.class.php
Log:
added caching for links
Modified: plog/branches/plog-1.1-ben/class/action/admin/admineditlinkaction.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/action/admin/admineditlinkaction.class.php 2005-05-22 16:46:23 UTC (rev 2045)
+++ plog/branches/plog-1.1-ben/class/action/admin/admineditlinkaction.class.php 2005-05-22 16:57:59 UTC (rev 2046)
@@ -5,6 +5,7 @@
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/mylinks.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
/**
* \ingroup Action
Modified: plog/branches/plog-1.1-ben/class/dao/mylinks.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/dao/mylinks.class.php 2005-05-22 16:46:23 UTC (rev 2045)
+++ plog/branches/plog-1.1-ben/class/dao/mylinks.class.php 2005-05-22 16:57:59 UTC (rev 2046)
@@ -22,31 +22,36 @@
*/
function getLinks( $blogId, $categoryId = 0, $page = -1, $itemsPerPage = 15 )
{
- // check if we're using any paging
- if( $page > -1 ) {
- $start = (($page - 1) * $itemsPerPage);
- $limits = " LIMIT $start, $itemsPerPage";
- }
- else
- $limits = "";
-
- $query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE blog_id = '".Db::qstr($blogId)."'";
- if( $categoryId != 0 )
- $query .= " AND category_id = '".Db::qstr($categoryId)."'";
- $query .= " ORDER BY id ASC $limits;";
-
- $result = $this->Execute( $query );
+ $blogLinks = $this->_cache->getData( $blogId, CACHE_BLOGLINKS );
- if( !$result )
- return false;
+ if ( !$blogLinks ) {
+ // check if we're using any paging
+ if( $page > -1 ) {
+ $start = (($page - 1) * $itemsPerPage);
+ $limits = " LIMIT $start, $itemsPerPage";
+ }
+ else
+ $limits = "";
+
+ $query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE blog_id = '".Db::qstr($blogId)."'";
+ if( $categoryId != 0 )
+ $query .= " AND category_id = '".Db::qstr($categoryId)."'";
+ $query .= " ORDER BY id ASC $limits;";
+
+ $result = $this->Execute( $query );
- $blogLinks = Array();
+ if( !$result )
+ return false;
- while( $row = $result->FetchRow()) {
- $blogLink = $this->_fillMyLinkInformation( $row );
- array_push( $blogLinks, $blogLink );
- }
+ $blogLinks = Array();
+ while( $row = $result->FetchRow()) {
+ $blogLink = $this->_fillMyLinkInformation( $row );
+ array_push( $blogLinks, $blogLink );
+ }
+ $this->_cache->setData( $blogId, CACHE_BLOGLINKS, $blogLinks );
+ }
+
return $blogLinks;
}
@@ -92,6 +97,8 @@
// mark the corresponding link categories as modified now
$linkCategories = new MyLinksCategories();
$linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
+
+ $this->_cache->removeData( $blogId, CACHE_BLOGLINKS );
}
return $result;
@@ -116,6 +123,8 @@
$linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
}*/
+ $this->_cache->removeData( $blogId, CACHE_BLOGLINKS );
+
return $result;
}
@@ -130,6 +139,8 @@
$result = $this->Execute( $query );
+ $this->_cache->removeData( $blogId, CACHE_BLOGLINKS );
+
return $result;
}
@@ -142,21 +153,28 @@
*/
function getMyLink( $linkId, $blogId = -1 )
{
- $query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE id = ".Db::qstr($linkId);
- if( $blogId > 0 )
- $query .= " AND blog_id = '".$blogId."';";
+ $blogLink = $this->_cache->getData( $linkId, CACHE_MYLINKS );
- $result = $this->Execute( $query );
+ if ( !$blogLink || ( $blogLink->getBlogId() != $blogId && $blogId != -1 ) ) {
+ $query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE id = ".Db::qstr($linkId);
+ if( $blogId > 0 )
+ $query .= " AND blog_id = '".$blogId."';";
- if( !$result )
- return false;
+ $result = $this->Execute( $query );
- if( $result->RecordCount() == 0 )
- return false;
+ if( !$result )
+ return false;
- $row = $result->FetchRow();
- $blogLink = $this->_fillMyLinkInformation( $row );
+ if( $result->RecordCount() == 0 )
+ return false;
+ $row = $result->FetchRow();
+ $blogLink = $this->_fillMyLinkInformation( $row );
+
+ // update the cache
+ $this->_cache->setData( $linkId, CACHE_MYLINKS, $blogLink );
+ }
+
return $blogLink;
}
@@ -183,11 +201,11 @@
if( !$result )
return false;
else {
- if( $result ) {
- // mark the corresponding link categories as modified now
- $linkCategories = new MyLinksCategories();
- $linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
- }
+ // mark the corresponding link categories as modified now
+ $linkCategories = new MyLinksCategories();
+ $linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
+
+ $this->_cache->removeData( $myLink->getBlogId(), CACHE_BLOGLINKS );
return true;
}
@@ -207,4 +225,4 @@
return $blogLink;
}
}
-?>
\ No newline at end of file
+?>
More information about the pLog-svn
mailing list