ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjectDataCache Class Reference

class ilObjectDataCache More...

+ Collaboration diagram for ilObjectDataCache:

Public Member Functions

 ilObjectDataCache ()
 deleteCachedEntry ($a_obj_id)
 lookupObjId ($a_ref_id)
 lookupTitle ($a_obj_id)
 lookupType ($a_obj_id)
 lookupOwner ($a_obj_id)
 lookupDescription ($a_obj_id)
 lookupLastUpdate ($a_obj_id)
 __isReferenceCached ($a_ref_id)
 checks whether an reference id is already in cache or not
 __isObjectCached ($a_obj_id)
 checks whether an object is aleady in cache or not
 __storeReference ($a_ref_id)
 Stores Reference in cache.
 __storeObjectData ($a_obj_id, $a_lang="")
 Stores object data in cache.
 preloadObjectCache ($a_obj_ids, $a_lang="")
 Stores object data in cache.
 preloadReferenceCache ($a_ref_ids, $a_incl_obj=true)

Data Fields

 $db = null
 $reference_cache = array()
 $object_data_cache = array()

Detailed Description

class ilObjectDataCache

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilObjectDataCache.php 20150 2009-06-08 18:02:33Z akill

This class caches some properties of the object_data table. Like title description owner obj_id

Definition at line 13 of file class.ilObjectDataCache.php.

Member Function Documentation

ilObjectDataCache::__isObjectCached (   $a_obj_id)

checks whether an object is aleady in cache or not

private

Parameters
int$a_obj_idobject id
Returns
boolean

Definition at line 119 of file class.ilObjectDataCache.php.

Referenced by lookupDescription(), lookupLastUpdate(), lookupOwner(), lookupTitle(), and lookupType().

{
static $cached = 0;
static $not_cached = 0;
if(@$this->object_data_cache[$a_obj_id])
{
#echo "Object ". ++$cached ."cached<br>";
return true;
}
#echo "Object ". ++$not_cached ." not cached<br>";
return false;
}

+ Here is the caller graph for this function:

ilObjectDataCache::__isReferenceCached (   $a_ref_id)

checks whether an reference id is already in cache or not

private

Parameters
int$a_ref_idreference id
Returns
boolean

Definition at line 96 of file class.ilObjectDataCache.php.

Referenced by lookupObjId().

{
#return false;
#static $cached = 0;
#static $not_cached = 0;
if(@$this->reference_cache[$a_ref_id])
{
#echo "Reference ". ++$cached ."cached<br>";
return true;
}
#echo "Reference ". ++$not_cached ." not cached<br>";
return false;
}

+ Here is the caller graph for this function:

ilObjectDataCache::__storeObjectData (   $a_obj_id,
  $a_lang = "" 
)

Stores object data in cache.

private

Parameters
int$a_obj_idobject id
Returns
bool

Definition at line 164 of file class.ilObjectDataCache.php.

References $ilDB, $q, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by lookupDescription(), lookupLastUpdate(), lookupObjId(), lookupOwner(), lookupTitle(), and lookupType().

{
global $ilDB, $objDefinition, $ilUser;
if (is_object($ilUser) && $a_lang == "")
{
$a_lang = $ilUser->getLanguage();
}
$query = "SELECT * FROM object_data WHERE obj_id = ".
$ilDB->quote($a_obj_id ,'integer');
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->object_data_cache[$a_obj_id]['title'] = $row->title;
$this->object_data_cache[$a_obj_id]['description'] = $row->description;
$this->object_data_cache[$a_obj_id]['type'] = $row->type;
$this->object_data_cache[$a_obj_id]['owner'] = $row->owner;
$this->object_data_cache[$a_obj_id]['last_update'] = $row->last_update;
//$ilBench->start("Tree", "fetchNodeData_readDefinition");
if (is_object($objDefinition))
{
$translation_type = $objDefinition->getTranslationType($row->type);
}
//$ilBench->stop("Tree", "fetchNodeData_readDefinition");
if ($translation_type == "db")
{
//$ilBench->start("Tree", "fetchNodeData_getTranslation");
$q = "SELECT title,description FROM object_translation ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id,'integer')." ".
"AND lang_code = ".$ilDB->quote($a_lang,'text')." ".
"AND NOT lang_default = 1";
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
if ($row)
{
$this->object_data_cache[$a_obj_id]['title'] = $row->title;
$this->object_data_cache[$a_obj_id]['description'] = $row->description;
}
//$ilBench->stop("Tree", "fetchNodeData_getTranslation");
}
}
return true;
}

+ Here is the caller graph for this function:

ilObjectDataCache::__storeReference (   $a_ref_id)

Stores Reference in cache.

Maybe it could be useful to find all references of that object andd store them also in the cache. But this would be an extra query.

private

Parameters
int$a_ref_idreference id
Returns
int $obj_id

Definition at line 144 of file class.ilObjectDataCache.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_ASSOC.

Referenced by lookupObjId().

{
global $ilDB;
$query = "SELECT obj_id FROM object_reference WHERE ref_id = ".$ilDB->quote($a_ref_id,'integer');
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
$this->reference_cache[$a_ref_id] = $row['obj_id'];
}
return (int) @$this->reference_cache[$a_ref_id];
}

+ Here is the caller graph for this function:

ilObjectDataCache::deleteCachedEntry (   $a_obj_id)

Definition at line 26 of file class.ilObjectDataCache.php.

{
unset($this->object_data_cache[$a_obj_id]);
}
ilObjectDataCache::ilObjectDataCache ( )

Definition at line 19 of file class.ilObjectDataCache.php.

References $ilDB.

{
global $ilDB;
$this->db =& $ilDB;
}
ilObjectDataCache::lookupDescription (   $a_obj_id)

Definition at line 70 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

{
if(!$this->__isObjectCached($a_obj_id))
{
$this->__storeObjectData($a_obj_id);
}
return @$this->object_data_cache[$a_obj_id]['description'];
}

+ Here is the call graph for this function:

ilObjectDataCache::lookupLastUpdate (   $a_obj_id)

Definition at line 79 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

{
if(!$this->__isObjectCached($a_obj_id))
{
$this->__storeObjectData($a_obj_id);
}
return @$this->object_data_cache[$a_obj_id]['last_update'];
}

+ Here is the call graph for this function:

ilObjectDataCache::lookupObjId (   $a_ref_id)

Definition at line 31 of file class.ilObjectDataCache.php.

References __isReferenceCached(), __storeObjectData(), and __storeReference().

{
if(!$this->__isReferenceCached($a_ref_id))
{
//echo"-objidmissed-$a_ref_id-";
$obj_id = $this->__storeReference($a_ref_id);
$this->__storeObjectData($obj_id);
}
return (int) @$this->reference_cache[$a_ref_id];
}

+ Here is the call graph for this function:

ilObjectDataCache::lookupOwner (   $a_obj_id)

Definition at line 61 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

{
if(!$this->__isObjectCached($a_obj_id))
{
$this->__storeObjectData($a_obj_id);
}
return @$this->object_data_cache[$a_obj_id]['owner'];
}

+ Here is the call graph for this function:

ilObjectDataCache::lookupTitle (   $a_obj_id)

Definition at line 42 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

{
if(!$this->__isObjectCached($a_obj_id))
{
$this->__storeObjectData($a_obj_id);
}
return @$this->object_data_cache[$a_obj_id]['title'];
}

+ Here is the call graph for this function:

ilObjectDataCache::lookupType (   $a_obj_id)

Definition at line 51 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

{
if(!$this->__isObjectCached($a_obj_id))
{
//echo"-typemissed-$a_obj_id-";
$this->__storeObjectData($a_obj_id);
}
return @$this->object_data_cache[$a_obj_id]['type'];
}

+ Here is the call graph for this function:

ilObjectDataCache::preloadObjectCache (   $a_obj_ids,
  $a_lang = "" 
)

Stores object data in cache.

private

Parameters
int$a_obj_idobject id
Returns
bool

Definition at line 220 of file class.ilObjectDataCache.php.

References $ilDB, $q, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by preloadReferenceCache().

{
global $ilDB, $objDefinition, $ilUser;
if (is_object($ilUser) && $a_lang == "")
{
$a_lang = $ilUser->getLanguage();
}
//echo "<br>-preloading-"; var_dump($a_obj_ids);
if (!is_array($a_obj_ids)) return;
if (count($a_obj_ids) == 0) return;
$query = "SELECT * FROM object_data ".
"WHERE ".$ilDB->in('obj_id',$a_obj_ids,false,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
//echo "<br>store_obj-".$row->obj_id."-".$row->type."-".$row->title."-";
$this->object_data_cache[$row->obj_id]['title'] = $row->title;
$this->object_data_cache[$row->obj_id]['description'] = $row->description;
$this->object_data_cache[$row->obj_id]['type'] = $row->type;
$this->object_data_cache[$row->obj_id]['owner'] = $row->owner;
$this->object_data_cache[$row->obj_id]['last_update'] = $row->last_update;
if (is_object($objDefinition))
{
$translation_type = $objDefinition->getTranslationType($row->type);
}
//$ilBench->stop("Tree", "fetchNodeData_readDefinition");
if ($translation_type == "db")
{
//$ilBench->start("Tree", "fetchNodeData_getTranslation");
$q = "SELECT title,description FROM object_translation ".
"WHERE obj_id = ".$ilDB->quote($row->obj_id,'integer')." ".
"AND lang_code = ".$ilDB->quote($a_lang,'text')." ".
"AND NOT lang_default = 1";
$r = $ilDB->query($q);
$row2 = $r->fetchRow(DB_FETCHMODE_OBJECT);
if ($row2)
{
$this->object_data_cache[$row->obj_id]['title'] = $row2->title;
$this->object_data_cache[$row->obj_id]['description'] = $row2->description;
}
//$ilBench->stop("Tree", "fetchNodeData_getTranslation");
}
}
}

+ Here is the caller graph for this function:

ilObjectDataCache::preloadReferenceCache (   $a_ref_ids,
  $a_incl_obj = true 
)

Definition at line 272 of file class.ilObjectDataCache.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_ASSOC, and preloadObjectCache().

{
global $ilDB;
if (!is_array($a_ref_ids)) return;
if (count($a_ref_ids) == 0) return;
$query = "SELECT ref_id, obj_id FROM object_reference ".
"WHERE ".$ilDB->in('ref_id',$a_ref_ids,false,'integer');
$res = $ilDB->query($query);
$obj_ids = array();
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
$this->reference_cache[$row['ref_id']] = $row['obj_id'];
//echo "<br>store_ref-".$row['ref_id']."-".$row['obj_id']."-";
$obj_ids[] = $row['obj_id'];
}
if ($a_incl_obj)
{
$this->preloadObjectCache($obj_ids);
}
}

+ Here is the call graph for this function:

Field Documentation

ilObjectDataCache::$db = null

Definition at line 15 of file class.ilObjectDataCache.php.

ilObjectDataCache::$object_data_cache = array()

Definition at line 17 of file class.ilObjectDataCache.php.

ilObjectDataCache::$reference_cache = array()

Definition at line 16 of file class.ilObjectDataCache.php.


The documentation for this class was generated from the following file: