ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
4include_once("./Services/Cache/classes/class.ilCache.php");
5include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
6
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}
An exception for terminatinating execution or to throw for unit testing.
Cache class.
setExpiresAfter($a_val)
Set expires after x seconds.
deleteByAdditionalKeys( $a_int_key1=null, $a_int_key2=null, $a_text_key1=null, $a_text_key2=null)
Delete by additional keys.
__construct()
Singleton constructor.
storeUnlimitedEntry($a_entry_id, $a_value, $a_key1=0, $a_key2=0, $a_key3='', $a_key4='')
Store an entry without an expired time.
static getInstance()
get singleton instance
readEntry($a_entry_id)
Get cahed entry if cache is active.
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.
static _getInstance()
get singleton instance
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc