ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCalendarCache.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Cache/classes/class.ilCache.php");
5 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
6 
14 class ilCalendarCache extends ilCache
15 {
16  private static $instance = null;
17 
22  public function __construct()
23  {
24  parent::__construct('ServicesCalendar', 'Calendar', true);
25  $this->setExpiresAfter(60 * ilCalendarSettings::_getInstance()->getCacheMinutes());
26  }
27 
32  public static function getInstance()
33  {
34  if (isset(self::$instance) and self::$instance) {
35  return self::$instance;
36  }
37  return self::$instance = new ilCalendarCache();
38  }
39 
45  public function readEntry($a_entry_id)
46  {
47  if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
48  return null;
49  }
50  return parent::readEntry($a_entry_id);
51  }
52 
59  public function storeEntry($a_entry_id, $a_value, $a_key1 = 0, $a_key2 = 0, $a_key3 = '', $a_key4 = '')
60  {
61  if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
62  return null;
63  }
64  parent::storeEntry($a_entry_id, $a_value, $a_key1, $a_key2, $a_key3, $a_key4);
65  }
66 
73  public function storeUnlimitedEntry($a_entry_id, $a_value, $a_key1 = 0, $a_key2 = 0, $a_key3 = '', $a_key4 = '')
74  {
75  if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
76  return null;
77  }
78  // Unlimited is a year
79  $this->setExpiresAfter(60 * 60 * 24 * 365);
80  parent::storeEntry($a_entry_id, $a_value, $a_key1, $a_key2, $a_key3, $a_key4);
81  $this->setExpiresAfter(ilCalendarSettings::_getInstance()->getCacheMinutes());
82  return true;
83  }
84 
89  public function deleteUserEntries($a_user_id)
90  {
91  return $this->deleteByAdditionalKeys($a_user_id);
92  }
93 }
static getInstance()
get singleton instance
static _getInstance()
get singleton instance
storeEntry($a_entry_id, $a_value, $a_key1=0, $a_key2=0, $a_key3='', $a_key4='')
Store an entry.
deleteUserEntries($a_user_id)
Delete user entries in cache.
storeUnlimitedEntry($a_entry_id, $a_value, $a_key1=0, $a_key2=0, $a_key3='', $a_key4='')
Store an entry without an expired time.
deleteByAdditionalKeys( $a_int_key1=null, $a_int_key2=null, $a_text_key1=null, $a_text_key2=null)
Delete by additional keys.
Cache class.
__construct()
Singleton constructor.
readEntry($a_entry_id)
Get cahed entry if cache is active.
setExpiresAfter($a_val)
Set expires after x seconds.