ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilGlobalCacheDBLayer Class Reference

Class ilGlobalCacheDBLayer. More...

+ Collaboration diagram for ilGlobalCacheDBLayer:

Public Member Functions

 getWhere ($field, $value, $case_sensitive=true)
 filter (array $data, $field, $value, $case_sensitive=true, $strip=true)
 where ($field, $value, $case_sensitive=true)
 get ($strip=true)
 setCachedResults ($cached_results)
 getCachedResults ()
 setRawData ($raw_data)
 getRawData ()
 setTableName ($table_name)
 getTableName ()
 setLoaded ($loaded)
 getLoaded ()
 setComponent ($component)
 getComponent ()
 setTtl ($ttl)
 getTtl ()

Static Public Member Functions

static getInstance ($component, $table_name)

Protected Member Functions

 __construct ($component, $table_name, $ttl=NULL)
 readFromCache ()
 writeToCache ()
 updateCachedResults ()

Protected Attributes

 $component = ''
 $loaded = false
 $table_name = ''
 $raw_data = array()
 $cached_results = array()
 $ttl = NULL
 $global_cache
 $wheres = array()

Static Protected Attributes

static $instances = array()

Detailed Description

Class ilGlobalCacheDBLayer.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 10 of file class.ilGlobalCacheDBLayer.php.

Constructor & Destructor Documentation

ilGlobalCacheDBLayer::__construct (   $component,
  $table_name,
  $ttl = NULL 
)
protected
Parameters
$component
$table_name
int$ttl

Definition at line 55 of file class.ilGlobalCacheDBLayer.php.

References $component, $table_name, $ttl, getInstance(), getLoaded(), readFromCache(), setComponent(), setLoaded(), setTableName(), setTtl(), and writeToCache().

{
$this->setTtl($ttl);
$this->global_cache = ilGlobalCache::getInstance($component);
$this->readFromCache();
if (! $this->getLoaded()) {
$this->readFromDB();
$this->writeToCache();
$this->setLoaded(true);
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilGlobalCacheDBLayer::filter ( array  $data,
  $field,
  $value,
  $case_sensitive = true,
  $strip = true 
)
Parameters
array$data
$field
$value
bool$case_sensitive
bool$strip
Returns
array

Definition at line 128 of file class.ilGlobalCacheDBLayer.php.

References $result, and getTableName().

Referenced by getWhere().

{
if (is_array($value)) {
$index = md5(serialize($value)) . $case_sensitive;
} else {
$index = $value . $case_sensitive;
}
if (isset($this->cached_results[$this->getTableName()][$field][$index])) {
return $this->cached_results[$this->getTableName()][$field][$index];
}
$result = array();
foreach ($data as $dat) {
if ($case_sensitive) {
if (is_array($value)) {
if (in_array($dat->{$field}, $value)) {
$result[] = $dat;
}
} elseif ($dat->{$field} == $value) {
$result[] = $dat;
}
} else {
if (is_array($value)) {
if (preg_grep("/" . $dat->{$field} . "/i", $value)) {
$result[] = $dat;
}
} elseif (strcasecmp($dat->{$field}, $value) == 0) {
$result[] = $dat;
}
}
}
if (count($result) == 1 AND $strip) {
}
$this->cached_results[$this->getTableName()][$field][$index] = $result;
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::get (   $strip = true)
Parameters
bool$strip
Returns
array

Definition at line 197 of file class.ilGlobalCacheDBLayer.php.

References $result.

{
$result = $this->getRawData();
foreach ($this->wheres as $ilGcDbWhere) {
$result = $this->filter($result, $ilGcDbWhere->getField(), $ilGcDbWhere->getValue(), $ilGcDbWhere->getCaseSensitive(), false);
}
if (count($result) == 1 AND $strip) {
// echo '<pre>' . print_r($result, 1) . '</pre>';
}
return $result;
}
ilGlobalCacheDBLayer::getCachedResults ( )
Returns
array

Definition at line 238 of file class.ilGlobalCacheDBLayer.php.

{
}
ilGlobalCacheDBLayer::getComponent ( )
Returns
string

Definition at line 302 of file class.ilGlobalCacheDBLayer.php.

{
}
static ilGlobalCacheDBLayer::getInstance (   $component,
  $table_name 
)
static
Parameters
$component
$table_name
Returns
ilGlobalCacheDBLayer

Definition at line 218 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct().

{
if (! isset(self::$instances[$component . $table_name])) {
self::$instances[$component . $table_name] = new self($component, $table_name);
}
return self::$instances[$component . $table_name];
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::getLoaded ( )
Returns
boolean

Definition at line 286 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct().

{
return $this->loaded;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::getRawData ( )
Returns
array

Definition at line 254 of file class.ilGlobalCacheDBLayer.php.

Referenced by getWhere(), and writeToCache().

{
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::getTableName ( )
Returns
string

Definition at line 270 of file class.ilGlobalCacheDBLayer.php.

Referenced by filter(), readFromCache(), and writeToCache().

{
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::getTtl ( )
Returns
int

Definition at line 318 of file class.ilGlobalCacheDBLayer.php.

Referenced by writeToCache().

{
return $this->ttl;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::getWhere (   $field,
  $value,
  $case_sensitive = true 
)
Parameters
$field
$value
bool$case_sensitive
Returns
array

Definition at line 112 of file class.ilGlobalCacheDBLayer.php.

References filter(), and getRawData().

{
return $this->filter($this->getRawData(), $field, $value, $case_sensitive);
}

+ Here is the call graph for this function:

ilGlobalCacheDBLayer::readFromCache ( )
protected

Definition at line 69 of file class.ilGlobalCacheDBLayer.php.

References $cached_results, getTableName(), setCachedResults(), setLoaded(), and setRawData().

Referenced by __construct().

{
if ($this->global_cache->isActive()) {
$data = $this->global_cache->get($this->getTableName() . '_raw_data');
$cached_results = $this->global_cache->get($this->getTableName() . '_cached_results');
if (is_array($data)) {
$this->setRawData($data);
$this->setLoaded(true);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::setCachedResults (   $cached_results)
Parameters
array$cached_results

Definition at line 230 of file class.ilGlobalCacheDBLayer.php.

Referenced by readFromCache().

{
$this->cached_results = $cached_results;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::setComponent (   $component)
Parameters
string$component

Definition at line 294 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct().

{
$this->component = $component;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::setLoaded (   $loaded)
Parameters
boolean$loaded

Definition at line 278 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct(), and readFromCache().

{
$this->loaded = $loaded;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::setRawData (   $raw_data)
Parameters
array$raw_data

Definition at line 246 of file class.ilGlobalCacheDBLayer.php.

Referenced by readFromCache().

{
$this->raw_data = $raw_data;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::setTableName (   $table_name)
Parameters
string$table_name

Definition at line 262 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct().

{
$this->table_name = $table_name;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::setTtl (   $ttl)
Parameters
int$ttl

Definition at line 310 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct().

{
$this->ttl = $ttl;
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::updateCachedResults ( )
protected

Definition at line 169 of file class.ilGlobalCacheDBLayer.php.

Referenced by writeToCache().

{
$this->global_cache->set($this->getTableName() . '_cached_results', $this->getCachedResults());
}

+ Here is the caller graph for this function:

ilGlobalCacheDBLayer::where (   $field,
  $value,
  $case_sensitive = true 
)
Parameters
$field
$value
bool$case_sensitive
Returns
$this

Definition at line 181 of file class.ilGlobalCacheDBLayer.php.

{
$ilGcDbWhere = new ilGcDbWhere();
$ilGcDbWhere->setField($field);
$ilGcDbWhere->setValue($value);
$ilGcDbWhere->setCaseSensitive($case_sensitive);
$this->wheres[] = $ilGcDbWhere;
return $this;
}
ilGlobalCacheDBLayer::writeToCache ( )
protected

Definition at line 82 of file class.ilGlobalCacheDBLayer.php.

References getRawData(), getTableName(), getTtl(), and updateCachedResults().

Referenced by __construct().

{
if ($this->global_cache->isActive()) {
$this->global_cache->set($this->getTableName() . '_raw_data', $this->getRawData(), $this->getTtl());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilGlobalCacheDBLayer::$cached_results = array()
protected

Definition at line 35 of file class.ilGlobalCacheDBLayer.php.

Referenced by readFromCache().

ilGlobalCacheDBLayer::$component = ''
protected

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

Referenced by __construct().

ilGlobalCacheDBLayer::$global_cache
protected

Definition at line 43 of file class.ilGlobalCacheDBLayer.php.

ilGlobalCacheDBLayer::$instances = array()
staticprotected

Definition at line 27 of file class.ilGlobalCacheDBLayer.php.

ilGlobalCacheDBLayer::$loaded = false
protected

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

ilGlobalCacheDBLayer::$raw_data = array()
protected

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

ilGlobalCacheDBLayer::$table_name = ''
protected

Definition at line 23 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct().

ilGlobalCacheDBLayer::$ttl = NULL
protected

Definition at line 39 of file class.ilGlobalCacheDBLayer.php.

Referenced by __construct().

ilGlobalCacheDBLayer::$wheres = array()
protected

Definition at line 47 of file class.ilGlobalCacheDBLayer.php.


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