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