| @@ -10,9 +10,11 @@ | ||
| 10 | 10 | defined( 'ABSPATH' ) || exit(); |
| 11 | 11 | |
| 12 | 12 | class LP_Course_Cache extends LP_Cache { |
| 13 | 13 | protected static $instance; |
| 14 | - protected $key_group_child = 'course'; | |
| 14 | + protected $key_group_child = 'course'; | |
| 15 | + protected $key_total_students_enrolled = 'total-students-enrolled'; | |
| 16 | + protected $key_total_students_enrolled_or_purchased = 'total-students-enrolled-or-purchased'; | |
| 15 | 17 | |
| 16 | 18 | /** |
| 17 | 19 | * Get instance |
| 18 | 20 | * |
| @@ -25,8 +27,47 @@ | ||
| 25 | 27 | |
| 26 | 28 | return self::$instance; |
| 27 | 29 | } |
| 28 | 30 | |
| 29 | - protected function __construct() { | |
| 30 | - parent::__construct(); | |
| 31 | + public function __construct( $has_thim_cache = false ) { | |
| 32 | + parent::__construct( $has_thim_cache ); | |
| 33 | + } | |
| 34 | + | |
| 35 | + public function set_total_students_enrolled( $course_id, $total ) { | |
| 36 | + $key = "{$course_id}/{$this->key_total_students_enrolled}"; | |
| 37 | + $this->set_cache( $key, $total ); | |
| 38 | + } | |
| 39 | + | |
| 40 | + public function get_total_students_enrolled( $course_id ) { | |
| 41 | + $key = "{$course_id}/{$this->key_total_students_enrolled}"; | |
| 42 | + return $this->get_cache( $key ); | |
| 43 | + } | |
| 44 | + | |
| 45 | + public function clean_total_students_enrolled( $course_id ) { | |
| 46 | + $key = "{$course_id}/{$this->key_total_students_enrolled}"; | |
| 47 | + $this->clear( $key ); | |
| 48 | + } | |
| 49 | + | |
| 50 | + public function set_total_students_enrolled_or_purchased( $course_id, $total ) { | |
| 51 | + $key = "{$course_id}/{$this->key_total_students_enrolled_or_purchased}"; | |
| 52 | + $this->set_cache( $key, $total ); | |
| 53 | + LP_Cache::cache_load_first( 'set', $key, $total ); | |
| 54 | + } | |
| 55 | + | |
| 56 | + public function get_total_students_enrolled_or_purchased( $course_id ) { | |
| 57 | + $key = "{$course_id}/{$this->key_total_students_enrolled_or_purchased}"; | |
| 58 | + $total = LP_Cache::cache_load_first( 'get', $key ); | |
| 59 | + if ( false !== $total ) { | |
| 60 | + return $total; | |
| 61 | + } | |
| 62 | + | |
| 63 | + $total = $this->get_cache( $key ); | |
| 64 | + LP_Cache::cache_load_first( 'set', $key, $total ); | |
| 65 | + | |
| 66 | + return $total; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public function clean_total_students_enrolled_or_purchased( $course_id ) { | |
| 70 | + $key = "{$course_id}/{$this->key_total_students_enrolled_or_purchased}"; | |
| 71 | + $this->clear( $key ); | |
| 31 | 72 | } |
| 32 | 73 | } |