Cache
[ class tree: Cache ] [ index: Cache ] [ all elements ]

Class: Cache_OutputCompression

Source Location: /Cache-1.5.7/Cache/OutputCompression.php

Class Overview

PEAR
   |
   --Cache
      |
      --Cache_Output
         |
         --Cache_OutputCompression

Cache using Output Buffering and contnet (gz) compression.


Author(s):

Version:

  • $Id: OutputCompression.php 315102 2011-08-17 19:38:20Z cweiske $

Variables

Methods


Inherited Variables

Inherited Methods

Class: Cache_Output

Cache_Output::end()
Cache_Output::endGet()
Returns the content of the output buffer but does not store it into the cache.
Cache_Output::endPrint()
Stores the content of the output buffer into the cache and prints the content.
Cache_Output::printContent()
Sends the data to the user.
Cache_Output::start()
starts the output buffering and returns an empty string or returns the cached output from the cache.
Cache_Output::_Cache_Output()
PEAR-Deconstructor

Class: Cache

Cache::Cache()
this Constructor set the Container Property as a Cache_Container|Cache_Error Object.
Cache::extSave()
Stores a dataset with additional userdefined data.
Cache::flush()
Flushes the cache - removes all data from it
Cache::garbageCollection()
Calls the garbage collector of the storage object with a certain probability
Cache::generateID()
Generates a "unique" ID for the given value
Cache::get()
Returns the requested dataset it if exists and is not expired
Cache::getCaching()
Returns the current caching state.
Cache::getUserdata()
Returns the userdata field of a cached data set.
Cache::isCached()
Checks if a dataset exists.
Cache::isExpired()
Checks if a dataset is expired
Cache::load()
Loads the given ID from the cache.
Cache::remove()
Removes the specified dataset from the cache.
Cache::save()
Stores the given data in the cache.
Cache::setCaching()
Enables or disables caching.
Cache::_Cache()

Class Details

[line 58]
Cache using Output Buffering and contnet (gz) compression.

* Usage example:

// place this somewhere in a central config file define(CACHE_STORAGE_CLASS, 'file'); // file storage needs a dir to put the cache files define(CACHE_DIR, '/var/tmp/');

// get a cache object $cache = new Cache_Output(CACHE_STORAGE_CLASS, array('cache_dir' => CACHE_DIR));

if (!($content = $cache->start($cache->generateID($REQUEST_URI)))) { print "hello world"; $cache->endPrint(+1000); } else { $cache->printContent(); }

OR

if (($content = $cache->start($cache->generateID($REQUEST_URI)))) { $cache->printContent(); die(); } print "hello world"; $cache->endPrint(+1000);

Based upon a case study from Christian Stocker and inspired by jpcache.

  • Author: Ulf Wendel <ulf.wendel@phpdoc.de>, Christian Stocker <chregu@phant.ch>
  • Version: $Id: OutputCompression.php 315102 2011-08-17 19:38:20Z cweiske $
  • Access: public


[ Top ]


Class Variables

$compression =  ''

[line 78]

Method used for compression

Type:   string


[ Top ]

$encoding =  'auto'

[line 69]

Encoding, what the user (its browser) of your website accepts

"auto" stands for test using $_SERVER['HTTP_ACCEPT_ENCODING']($HTTP_ACCEPT_ENCODING).


Type:   string


[ Top ]



Method Detail

Cache_OutputCompression (Constructor)   [line 88]

Cache_OutputCompression Cache_OutputCompression( string $container, [array $container_options = ''], [string $encoding = 'auto'])

Sets the storage details and the content encoding used (if not autodetection)

Parameters:

string   $container   —  Name of container class
array   $container_options   —  Array with container class options
string   $encoding   —  content encoding mode - auto => test which encoding the user accepts

[ Top ]

_Cache_OutputCompression (Destructor)   [line 99]

void _Cache_OutputCompression( )

Call parent deconstructor.

[ Top ]

end   [line 133]

void end( [ $expire = 0], [ $userdata = ''])

Stops the output buffering, saves it to the cache and returns the _compressed_ content.

If you need the uncompressed content for further procession before it's saved in the cache use endGet(). endGet() does _not compress_.


Overrides Cache_Output::end() (parent method not documented)

Parameters:

   $expire   — 
   $userdata   — 

[ Top ]

endPrint   [line 148]

void endPrint( [ $expire = 0], [ $userdata = ''])


Overrides Cache_Output::endPrint() (Stores the content of the output buffer into the cache and prints the content.)

Parameters:

   $expire   — 
   $userdata   — 

[ Top ]

extSave   [line 158]

void extSave( $id, $cachedata, $userdata, [ $expires = 0], [ $group = 'default'])

Saves the given data to the cache.

Overrides Cache::extSave() (Stores a dataset with additional userdefined data.)

Parameters:

   $id   — 
   $cachedata   — 
   $userdata   — 
   $expires   — 
   $group   — 

[ Top ]

generateID   [line 105]

void generateID( $variable)


Overrides Cache::generateID() (Generates a "unique" ID for the given value)

Parameters:

   $variable   — 

[ Top ]

get   [line 112]

void get( $id, $group)


Overrides Cache::get() (Returns the requested dataset it if exists and is not expired)

Parameters:

   $id   — 
   $group   — 

[ Top ]

getEncoding   [line 238]

void getEncoding( )

Returns the encoding to be used for the data transmission to the client.

[ Top ]

isCompressed   [line 215]

string isCompressed( )

Returns the encoding method of the current dataset.
  • Return: Empty string (which evaluates to false) means no compression
  • Access: public

[ Top ]

printContent   [line 181]

void printContent( [string $content = ''])

Sends the compressed data to the user.
  • Access: public

Overrides Cache_Output::printContent() (Sends the data to the user.)

Parameters:

string   $content   — 

[ Top ]

setEncoding   [line 227]

void setEncoding( [string $encoding = 'auto'])

Sets the encoding to be used.

Parameters:

string   $encoding   —  "auto" means autodetect for every client

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:44:50 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.