ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCalendarCache.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
5 
12 class ilCalendarCache extends ilCache
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 }
deleteByAdditionalKeys(?int $a_int_key1=null, ?int $a_int_key2=null, ?string $a_text_key1=null, ?string $a_text_key2=null)
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)
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)
readEntry(string $a_id)
Get cached entry if cache is active.
setExpiresAfter(int $a_val)
Set expires after x seconds.
deleteUserEntries(int $a_user_id)
Delete user entries in cache.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
static ilCalendarCache $instance