QuizAttempts.php
85 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Handle quiz attempt cache data |
| 4 | * |
| 5 | * @package Tutor\Cache |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 2.0.6 |
| 9 | */ |
| 10 | |
| 11 | namespace Tutor\Cache; |
| 12 | |
| 13 | use Tutor\Cache\AbstractCache; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * User data caching |
| 21 | * Get Set & check |
| 22 | * |
| 23 | * @since 2.0.6 |
| 24 | */ |
| 25 | class QuizAttempts extends AbstractCache { |
| 26 | |
| 27 | /** |
| 28 | * Key for cache identifier |
| 29 | * |
| 30 | * @var string |
| 31 | * |
| 32 | * @since 2.0.6 |
| 33 | */ |
| 34 | private const KEY = 'tutor_quiz_attempts_count'; |
| 35 | |
| 36 | /** |
| 37 | * Cache expire time |
| 38 | * |
| 39 | * @var string |
| 40 | * |
| 41 | * @since 2.0.6 |
| 42 | */ |
| 43 | private const HOUR_IN_SECONDS = 1800; |
| 44 | |
| 45 | /** |
| 46 | * Data for caching |
| 47 | * |
| 48 | * @var string |
| 49 | * |
| 50 | * @since 2.0.6 |
| 51 | */ |
| 52 | public $data; |
| 53 | |
| 54 | /** |
| 55 | * Key |
| 56 | * |
| 57 | * @since 2.0.6 |
| 58 | * @return string |
| 59 | */ |
| 60 | public function key(): string { |
| 61 | return self::KEY; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Cache data |
| 66 | * |
| 67 | * @since 2.0.6 |
| 68 | * @return object |
| 69 | */ |
| 70 | public function cache_data() { |
| 71 | return $this->data; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Cache time |
| 76 | * |
| 77 | * @since 2.0.6 |
| 78 | * @return int |
| 79 | */ |
| 80 | public function cache_time(): int { |
| 81 | $cache_time = self::HOUR_IN_SECONDS; |
| 82 | return $cache_time; |
| 83 | } |
| 84 | } |
| 85 |