From 674002c02f5e61870b50b121c2b48e54fcce92c0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 22 Sep 2021 09:46:20 +0200 Subject: [PATCH] init class variables for internal cache, add method to clear cache --- SeedDMS_Core/Core/inc.ClassFolder.php | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index c29410ed8..76ad08db8 100644 --- a/SeedDMS_Core/Core/inc.ClassFolder.php +++ b/SeedDMS_Core/Core/inc.ClassFolder.php @@ -79,22 +79,22 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { protected $_date; /** - * @var SeedDMS_Core_Folder + * @var SeedDMS_Core_Folder cached parent folder */ protected $_parent; /** - * @var SeedDMS_Core_User + * @var SeedDMS_Core_User cached owner of folder */ protected $_owner; /** - * @var SeedDMS_Core_Folder[] + * @var SeedDMS_Core_Folder[] cached array of sub folders */ protected $_subFolders; /** - * @var SeedDMS_Core_Document[] + * @var SeedDMS_Core_Document[] cache array of child documents */ protected $_documents; @@ -126,7 +126,26 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $this->_inheritAccess = $inheritAccess; $this->_defaultAccess = $defaultAccess; $this->_sequence = $sequence; - $this->_notifyList = array(); + $this->_notifyList = array(); + /* Cache */ + $this->clearCache(); + } /* }}} */ + + /** + * Clear cache of this instance. + * + * The result of some expensive database actions (e.g. get all subfolders + * or documents) will be saved in a class variable to speed up consecutive + * calls of the same method. If a second call of the same method shall not + * use the cache, then it must be cleared. + * + */ + public function clearCache() { /* {{{ */ + $this->_parent = null; + $this->_owner = null; + $this->_subFolders = null; + $this->_documents = null; + $this->_accessList = null; } /* }}} */ /**