| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class LP_Courses_Cache |
| 5 |
* |
| 6 |
* @author tungnx |
| 7 |
* @since 4.1.5 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
defined( 'ABSPATH' ) || exit(); |
| 11 |
|
| 12 |
class LP_Courses_Cache extends LP_Cache { |
| 13 |
/** |
| 14 |
* @var LP_Courses_Cache |
| 15 |
*/ |
| 16 |
protected static $instance; |
| 17 |
/** |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
protected $key_group_child = 'courses'; |
| 21 |
/** |
| 22 |
* @var string Save list keys cached to clear |
| 23 |
*/ |
| 24 |
public static $keys = 'keys'; |
| 25 |
|
| 26 |
/** |
| 27 |
* Get instance |
| 28 |
* |
| 29 |
* @return self |
| 30 |
*/ |
| 31 |
public static function instance(): self { |
| 32 |
if ( is_null( self::$instance ) ) { |
| 33 |
self::$instance = new self(); |
| 34 |
} |
| 35 |
|
| 36 |
return self::$instance; |
| 37 |
} |
| 38 |
|
| 39 |
protected function __construct() { |
| 40 |
parent::__construct(); |
| 41 |
} |
| 42 |
|
| 43 |
public function save_cache_keys( string $key_cache ) { |
| 44 |
$keys_cache = $this->get_cache( self::$keys ); |
| 45 |
if ( false === $keys_cache ) { |
| 46 |
$keys_cache = array(); |
| 47 |
} |
| 48 |
|
| 49 |
$keys_cache[] = $key_cache; |
| 50 |
$this->set_cache( self::$keys, $keys_cache ); |
| 51 |
} |
| 52 |
} |
| 53 |
|