ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarCache.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
27{
28 private static ?ilCalendarCache $instance = null;
29
30 public function __construct()
31 {
32 parent::__construct('ServicesCalendar', 'Calendar', true);
33 $this->setExpiresAfter(60 * ilCalendarSettings::_getInstance()->getCacheMinutes());
34 }
35
36 public static function getInstance(): self
37 {
38 if (!self::$instance instanceof self) {
39 self::$instance = new self();
40 }
41 return self::$instance;
42 }
43
47 protected function readEntry(string $a_id): bool
48 {
49 if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
50 return false;
51 }
52 return parent::readEntry($a_id);
53 }
54
55 public function storeEntry(
56 string $a_id,
57 string $a_value,
58 ?int $a_int_key1 = null,
59 ?int $a_int_key2 = null,
60 ?string $a_text_key1 = null,
61 ?string $a_text_key2 = null
62 ): void {
63 if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
64 return;
65 }
66 parent::storeEntry($a_id, $a_value, $a_int_key1, $a_int_key2, $a_text_key1, $a_text_key2);
67 }
68
72 public function storeUnlimitedEntry(
73 string $a_entry_id,
74 string $a_value,
75 ?int $a_key1 = 0,
76 ?int $a_key2 = 0,
77 ?string $a_key3 = '',
78 ?string $a_key4 = ''
79 ): void {
80 if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
81 return;
82 }
83 // Unlimited is a year
84 $this->setExpiresAfter(60 * 60 * 24 * 365);
85 parent::storeEntry($a_entry_id, $a_value, $a_key1, $a_key2, $a_key3, $a_key4);
86 $this->setExpiresAfter(ilCalendarSettings::_getInstance()->getCacheMinutes());
87 }
88
92 public function deleteUserEntries(int $a_user_id): void
93 {
94 $this->deleteByAdditionalKeys($a_user_id);
95 }
96}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setExpiresAfter(int $a_val)
Set expires after x seconds.
readEntry(string $a_id)
Get cached entry if cache is active.
deleteUserEntries(int $a_user_id)
Delete user entries in cache.
storeEntry(string $a_id, string $a_value, ?int $a_int_key1=null, ?int $a_int_key2=null, ?string $a_text_key1=null, ?string $a_text_key2=null)
static ilCalendarCache $instance
storeUnlimitedEntry(string $a_entry_id, string $a_value, ?int $a_key1=0, ?int $a_key2=0, ?string $a_key3='', ?string $a_key4='')
Store an entry without an expired time (one year)
Stores all calendar relevant settings.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))