| @@ -1,20 +1,20 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Cache abstract for implementing by the derived class |
| 4 | 4 | * |
| 5 | - * @package Tutor\Cache | |
| 6 | - * @author Themeum <support@themeum.com> | |
| 7 | - * @link https://themeum.com | |
| 8 | - * @since 2.0.6 | |
| 5 | + * @package Tutor\Cache | |
| 6 | + * | |
| 7 | + * @author Themeum | |
| 8 | + * | |
| 9 | + * @since v2.0.6 | |
| 9 | 10 | */ |
| 10 | 11 | |
| 11 | 12 | namespace Tutor\Cache; |
| 12 | 13 | |
| 13 | 14 | /** |
| 14 | - * AbstractCache class | |
| 15 | - * | |
| 16 | - * @since 2.0.6 | |
| 15 | + * Containing abstract and regular method for | |
| 16 | + * caching | |
| 17 | 17 | */ |
| 18 | 18 | abstract class AbstractCache { |
| 19 | 19 | |
| 20 | 20 | /** |
| @@ -40,10 +40,11 @@ | ||
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Set cache data |
| 43 | 43 | * |
| 44 | - * @since 2.0.6 | |
| 45 | 44 | * @return void |
| 45 | + * | |
| 46 | + * @since v2.0.6 | |
| 46 | 47 | */ |
| 47 | 48 | public function set_cache(): void { |
| 48 | 49 | do_action( 'tutor_cache_before_' . $this->key(), $this->cache_data() ); |
| 49 | 50 | set_transient( $this->key(), $this->cache_data(), $this->cache_time() ); |
| @@ -52,10 +53,11 @@ | ||
| 52 | 53 | |
| 53 | 54 | /** |
| 54 | 55 | * Get user data from cache |
| 55 | 56 | * |
| 56 | - * @since 2.0.6 | |
| 57 | 57 | * @return object cache data |
| 58 | + * | |
| 59 | + * @since v2.0.6 | |
| 58 | 60 | */ |
| 59 | 61 | public function get_cache() { |
| 60 | 62 | $data = get_transient( $this->key() ); |
| 61 | 63 | return $data; |
| @@ -64,10 +66,11 @@ | ||
| 64 | 66 | /** |
| 65 | 67 | * If cache don't have value or expired or not exists |
| 66 | 68 | * will return false |
| 67 | 69 | * |
| 68 | - * @since 2.0.6 | |
| 69 | - * @return bool true on success, false on fail | |
| 70 | + * @return bool | true on success, false on fail | |
| 71 | + * | |
| 72 | + * @since v2.0.6 | |
| 70 | 73 | */ |
| 71 | 74 | public function has_cache(): bool { |
| 72 | 75 | return $this->get_cache() ? true : false; |
| 73 | 76 | } |
| @@ -74,16 +77,12 @@ | ||
| 74 | 77 | |
| 75 | 78 | /** |
| 76 | 79 | * Delete cache |
| 77 | 80 | * |
| 78 | - * @since 2.0.6 | |
| 79 | 81 | * @return void |
| 82 | + * | |
| 83 | + * @since v2.0.6 | |
| 80 | 84 | */ |
| 81 | 85 | public function delete_cache(): void { |
| 82 | - delete_transient( $this->key() ); | |
| 83 | - | |
| 84 | - // Clear data after delete cache. | |
| 85 | - if ( isset( $this->data ) ) { | |
| 86 | - $this->data = ''; | |
| 87 | - } | |
| 86 | + delete_transient( $this->key ); | |
| 88 | 87 | } |
| 89 | 88 | } |