From 6cd76ee2ffc7bd8c882660a0d5cdd67e8a15087b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 13 Jan 2020 12:53:05 -0500 Subject: [PATCH] Clear cache after loading Events so as to free ram. --- web/includes/Storage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/includes/Storage.php b/web/includes/Storage.php index 286cec8da..a127acd2f 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -116,13 +116,14 @@ class Storage extends ZM_Object { $used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id())); do { - # Do in batches of 1000 so as to not useup all ram + # Do in batches of 1000 so as to not useup all ram, Event will do caching though... $events = Event::find(array('StorageId'=>$this->Id(), 'DiskSpace'=>null), array('limit'=>1000)); foreach ( $events as $Event ) { $Event->Storage($this); // Prevent further db hit # DiskSpace will update the event $used += $Event->DiskSpace(); } #end foreach + Event::clear_cache(); } while ( count($events) == 1000 ); $this->{'DiskSpace'} = $used; }