ILIAS  release_8 Revision v8.24
class.ilCalendarCache.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
5
13{
14 private static ?ilCalendarCache $instance = null;
15
16 public function __construct()
17 {
18 parent::__construct('ServicesCalendar', 'Calendar', true);
19 $this->setExpiresAfter(60 * ilCalendarSettings::_getInstance()->getCacheMinutes());
20 }
21
22 public static function getInstance(): self
23 {
24 if (!self::$instance instanceof self) {
25 self::$instance = new self();
26 }
27 return self::$instance;
28 }
29
33 protected function readEntry(string $a_id): bool
34 {
35 if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
36 return false;
37 }
38 return parent::readEntry($a_id);
39 }
40
41 public function storeEntry(
42 string $a_id,
43 string $a_value,
44 ?int $a_int_key1 = null,
45 ?int $a_int_key2 = null,
46 ?string $a_text_key1 = null,
47 ?string $a_text_key2 = null
48 ): void {
49 if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
50 return;
51 }
52 parent::storeEntry($a_id, $a_value, $a_int_key1, $a_int_key2, $a_text_key1, $a_text_key2);
53 }
54
58 public function storeUnlimitedEntry(
59 string $a_entry_id,
60 string $a_value,
61 ?int $a_key1 = 0,
62 ?int $a_key2 = 0,
63 ?string $a_key3 = '',
64 ?string $a_key4 = ''
65 ): void {
66 if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
67 return;
68 }
69 // Unlimited is a year
70 $this->setExpiresAfter(60 * 60 * 24 * 365);
71 parent::storeEntry($a_entry_id, $a_value, $a_key1, $a_key2, $a_key3, $a_key4);
72 $this->setExpiresAfter(ilCalendarSettings::_getInstance()->getCacheMinutes());
73 }
74
78 public function deleteUserEntries(int $a_user_id): void
79 {
80 $this->deleteByAdditionalKeys($a_user_id);
81 }
82}
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.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc