.

DAOCache Class Reference
[Model]

Table Definition for cache entries. More...

Inheritance diagram for DAOCache:
DataObjectBase ICacheItem IDataObject IActionSource ISearchAdapter IDBTable IDBWhereHolder

List of all members.

Public Member Functions

  get_content_compressed ()
  Return the content gzip compressed.
  get_content_plain ()
  Return the content in plain form.
  get_creationdate ()
  Return creation date.
  get_data ()
  Return data associated with this item.
  get_expirationdate ()
  Return expiration date.
  set_content_compressed ($content)
  set_content_plain ($content)
  set_keys ($keys, $force_where=false)
  Set cache keys.

Public Attributes

  $content_gzip
  $creationdate
  $data
  $expirationdate
  $id
  $key0
  $key1
  $key2

Protected Member Functions

  configure_insert_query ($query)
  Configure an insert query.
  create_table_object ()
  Create the table object describing this dataobejcts table.

Detailed Description

Table Definition for cache entries.

The cache stores the cached content gzipped to save database space

Author:
Gerd Riesselmann

Definition at line 10 of file cache.model.php.


Member Function Documentation

DAOCache::configure_insert_query ( query  )  [protected]

Configure an insert query.

Parameters:
DBQueryInsert  $query

Reimplemented from DataObjectBase.

Definition at line 123 of file cache.model.php.

00123                                                           {
00124                 $query->set_policy(DBQueryInsert::IGNORE);
00125                 parent::configure_insert_query($query);
00126         }
DAOCache::create_table_object (  )  [protected]

Create the table object describing this dataobejcts table.

Reimplemented from DataObjectBase.

Definition at line 100 of file cache.model.php.

00100                                                  {
00101             return new DBTable(
00102                 'cache',
00103                         array(
00104                                 new DBFieldInt('id', null, DBFieldInt::AUTOINCREMENT | DBFieldInt::UNSIGNED | DBFieldInt::NOT_NULL),
00105                                 new DBFieldText('key0', 255), 
00106                                 new DBFieldText('key1', 255),
00107                                 new DBFieldText('key2', 255),
00108                                 new DBFieldBlob('content_gzip', DBFieldText::BLOB_LENGTH_LARGE),
00109                                 new DBFieldDateTime('creationdate', null, DBFieldDateTime::TIMESTAMP),
00110                                 new DBFieldDateTime('expirationdate', null, DBFieldDateTime::NOT_NULL),
00111                                 new DBFieldSerialized('data', DBFieldText::BLOB_LENGTH_SMALL)
00112                         ),
00113                         'id'                    
00114             );
00115         }
DAOCache::get_content_compressed (  ) 

Return the content gzip compressed.

Returns:
string

Implements ICacheItem.

Definition at line 83 of file cache.model.php.

00083                                                  {
00084                 return $this->content_gzip;
00085         }
DAOCache::get_content_plain (  ) 

Return the content in plain form.

Returns:
string

Implements ICacheItem.

Definition at line 75 of file cache.model.php.

00075                                             {
00076                 $ret = $this->content_gzip;
00077                 if ($ret && function_exists('gzinflate')) {
00078                         $ret = gzinflate($ret);
00079                 }
00080                 return $ret;
00081         }
DAOCache::get_creationdate (  ) 

Return creation date.

Returns:
datetime

Implements ICacheItem.

Definition at line 53 of file cache.model.php.

00053                                            {
00054                 return $this->creationdate;
00055         }       
DAOCache::get_data (  ) 

Return data associated with this item.

Returns:
mixed

Implements ICacheItem.

Definition at line 71 of file cache.model.php.

00071                                    {
00072                 return $this->data;
00073         }
DAOCache::get_expirationdate (  ) 

Return expiration date.

Returns:
datetime

Implements ICacheItem.

Definition at line 62 of file cache.model.php.

00062                                              {
00063                 return $this->expirationdate;
00064         }
DAOCache::set_content_compressed ( content  ) 

Definition at line 94 of file cache.model.php.

00094                                                          {
00095                 $this->content_gzip = $content;
00096         }
DAOCache::set_content_plain ( content  ) 

Definition at line 87 of file cache.model.php.

00087                                                     {
00088                 if (function_exists('gzdeflate')) {
00089                         $content = gzdeflate($content, 9);
00090                 }
00091                 $this->content_gzip = $content;         
00092         }
DAOCache::set_keys ( keys,
force_where = false  
)

Set cache keys.

Parameters:
Array  Array of keys that are set as key0, key1 etc
Boolean  If TRUE a phrase keyX like 'valueX' etc is added to where clause for each key

Definition at line 26 of file cache.model.php.

00026                                                               {
00027                 $c = count($keys);
00028                 if ($c > 3) {
00029                         $c = 3;
00030                 }
00031                 for ($i = 0; $i < $c; $i++) {
00032                         $name = 'key' . $i;
00033                         if ($force_where) {
00034                                 $this->add_where($name, '=', $keys[$i]);
00035                         }
00036                         else {
00037                                 $val = $keys[$i];
00038                                 if (!empty($val)) {
00039                                         $this->$name = $val;
00040                                 }
00041                                 else {
00042                                         $this->add_where($name, DBWhere::OP_IS_NULL);
00043                                 }
00044                         }
00045                 }
00046         }

Member Data Documentation

DAOCache::$content_gzip

Definition at line 15 of file cache.model.php.

DAOCache::$creationdate

Definition at line 17 of file cache.model.php.

DAOCache::$data

Definition at line 16 of file cache.model.php.

DAOCache::$expirationdate

Definition at line 18 of file cache.model.php.

DAOCache::$id

Definition at line 11 of file cache.model.php.

DAOCache::$key0

Definition at line 12 of file cache.model.php.

DAOCache::$key1

Definition at line 13 of file cache.model.php.

DAOCache::$key2

Definition at line 14 of file cache.model.php.


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