ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.arConnectorCache.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
14  private $ttl;
18  private $arConnectorDB;
22  private $cache;
23  const CACHE_TTL_SECONDS = 180;
24 
25 
32  public function __construct(arConnector $arConnectorDB, int $ttl = self::CACHE_TTL_SECONDS)
33  {
34  $this->ttl = $ttl;
37  }
38 
39 
45  public function nextID(ActiveRecord $ar)
46  {
47  return $this->arConnectorDB->nextID($ar);
48  }
49 
50 
56  public function checkConnection(ActiveRecord $ar)
57  {
58  return $this->arConnectorDB->checkConnection($ar);
59  }
60 
61 
68  public function installDatabase(ActiveRecord $ar, $fields)
69  {
70  return $this->arConnectorDB->installDatabase($ar, $fields);
71  }
72 
73 
79  public function updateDatabase(ActiveRecord $ar)
80  {
81  return $this->arConnectorDB->updateDatabase($ar);
82  }
83 
84 
90  public function resetDatabase(ActiveRecord $ar)
91  {
92  return $this->arConnectorDB->resetDatabase($ar);
93  }
94 
95 
101  public function truncateDatabase(ActiveRecord $ar)
102  {
103  $this->arConnectorDB->truncateDatabase($ar);
104  }
105 
106 
113  public function checkTableExists(ActiveRecord $ar)
114  {
115  return $this->arConnectorDB->checkTableExists($ar);
116  }
117 
118 
125  public function checkFieldExists(ActiveRecord $ar, $field_name)
126  {
127  return $this->arConnectorDB->checkFieldExists($ar, $field_name);
128  }
129 
130 
138  public function removeField(ActiveRecord $ar, $field_name)
139  {
140  return $this->arConnectorDB->removeField($ar, $field_name);
141  }
142 
143 
152  public function renameField(ActiveRecord $ar, $old_name, $new_name)
153  {
154  return $this->arConnectorDB->renameField($ar, $old_name, $new_name);
155  }
156 
157 
163  public function create(ActiveRecord $ar)
164  {
165  $this->arConnectorDB->create($ar);
166  $this->storeActiveRecordInCache($ar);
167  }
168 
169 
175  public function read(ActiveRecord $ar)
176  {
177  if ($this->cache->isActive()) {
178  $key = $ar->getConnectorContainerName() . "_" . $ar->getPrimaryFieldValue();
179  $cached_value = $this->cache->get($key);
180  if (is_array($cached_value)) {
181  return $cached_value;
182  }
183 
184  if ($cached_value instanceof stdClass) {
185  return [$cached_value];
186  }
187  }
188 
189  $results = $this->arConnectorDB->read($ar);
190 
191  if ($this->cache->isActive()) {
192  $key = $ar->getConnectorContainerName() . "_" . $ar->getPrimaryFieldValue();
193 
194  $this->cache->set($key, $results, self::CACHE_TTL_SECONDS);
195  }
196 
197  return $results;
198  }
199 
200 
206  public function update(ActiveRecord $ar)
207  {
208  $this->arConnectorDB->update($ar);
209  $this->storeActiveRecordInCache($ar);
210  }
211 
212 
218  public function delete(ActiveRecord $ar)
219  {
220  $this->arConnectorDB->delete($ar);
221 
222  if ($this->cache->isActive()) {
223  $key = $ar->getConnectorContainerName() . "_" . $ar->getPrimaryFieldValue();
224  $this->cache->delete($key);
225  }
226  }
227 
228 
234  public function readSet(ActiveRecordList $arl)
235  {
236  return $this->arConnectorDB->readSet($arl);
237  }
238 
239 
245  public function affectedRows(ActiveRecordList $arl)
246  {
247  return $this->arConnectorDB->affectedRows($arl);
248  }
249 
250 
257  public function quote($value, $type)
258  {
259  return $this->arConnectorDB->quote($value, $type);
260  }
261 
262 
266  public function updateIndices(ActiveRecord $ar)
267  {
268  $this->arConnectorDB->updateIndices($ar);
269  }
270 
271 
280  {
281  if ($this->cache->isActive()) {
282  $key = $ar->getConnectorContainerName() . "_" . $ar->getPrimaryFieldValue();
283  $value = $ar->__asStdClass();
284 
285  $this->cache->set($key, $value, self::CACHE_TTL_SECONDS);
286  }
287  }
288 }
nextID(ActiveRecord $ar)
__construct(arConnector $arConnectorDB, int $ttl=self::CACHE_TTL_SECONDS)
ilGSStorageCache constructor.
read(ActiveRecord $ar)
renameField(ActiveRecord $ar, $old_name, $new_name)
installDatabase(ActiveRecord $ar, $fields)
Class arConnectorDB.
updateIndices(ActiveRecord $ar)
checkConnection(ActiveRecord $ar)
readSet(ActiveRecordList $arl)
$type
Class ActiveRecord.
static getInstance($component)
Class ActiveRecordList.
updateIndices(ActiveRecord $ar)
updateDatabase(ActiveRecord $ar)
Class arConnector.
resetDatabase(ActiveRecord $ar)
updateDatabase(ActiveRecord $ar)
resetDatabase(ActiveRecord $ar)
nextID(ActiveRecord $ar)
checkConnection(ActiveRecord $ar)
removeField(ActiveRecord $ar, $field_name)
quote($value, $type)
affectedRows(ActiveRecordList $arl)
truncateDatabase(ActiveRecord $ar)
checkFieldExists(ActiveRecord $ar, $field_name)
update(ActiveRecord $ar)
readSet(ActiveRecordList $arl)
Class ilGSStorageCache.
renameField(ActiveRecord $ar, $old_name, $new_name)
create(ActiveRecord $ar)
affectedRows(ActiveRecordList $arl)
checkTableExists(ActiveRecord $ar)
read(ActiveRecord $ar)
$results
Definition: svg-scanner.php:47
update(ActiveRecord $ar)
storeActiveRecordInCache(ActiveRecord $ar)
Stores an active record into the Cache.
delete(ActiveRecord $ar)
removeField(ActiveRecord $ar, $field_name)
create(ActiveRecord $ar)
checkTableExists(ActiveRecord $ar)
$key
Definition: croninfo.php:18
checkFieldExists(ActiveRecord $ar, $field_name)
truncateDatabase(ActiveRecord $ar)
installDatabase(ActiveRecord $ar, $fields)