PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.7
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.7
4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 4.2.1 All 138 releases
learnpress / inc / cache / class-lp-course-cache.php

class-lp-course-cache.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.7, at inc/cache/class-lp-course-cache.php

74 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class LP_Course_Cache
5 *
6 * @author tungnx
7 * @since 4.0.9
8 * @version 1.0.0
9 */
10 defined( 'ABSPATH' ) || exit();
11
12 class LP_Course_Cache extends LP_Cache {
13 protected static $instance;
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';
17
18 /**
19 * Get instance
20 *
21 * @return self
22 */
23 public static function instance(): self {
24 if ( is_null( self::$instance ) ) {
25 self::$instance = new self();
26 }
27
28 return self::$instance;
29 }
30
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 );
72 }
73 }
74