From f7e23598187599785e1caccd79ac16469161cacf Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 13 Jan 2020 10:57:56 -0500 Subject: [PATCH] Implement a clear_cache function so that we can free up cached objects --- web/includes/Event.php | 4 ++++ web/includes/Object.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/web/includes/Event.php b/web/includes/Event.php index da633f439..2ed20f95e 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -47,6 +47,10 @@ class Event extends ZM_Object { return ZM_Object::_find_one(get_class(), $parameters, $options); } + public static function clear_cahce() { + return ZM_Object::_clear_cache(get_class()); + } + public function Storage( $new = null ) { if ( $new ) { $this->{'Storage'} = $new; diff --git a/web/includes/Object.php b/web/includes/Object.php index bf647c230..cc595cd74 100644 --- a/web/includes/Object.php +++ b/web/includes/Object.php @@ -128,6 +128,11 @@ class ZM_Object { return $results[0]; } + public static function _clear_cache($class) { + global $object_cache; + $object_cache[$class] = array(); + } + public static function Objects_Indexed_By_Id($class) { $results = array(); foreach ( ZM_Object::_find($class, null, array('order'=>'lower(Name)')) as $Object ) {