rapila
Public Member Functions | Static Public Member Functions | List of all members
Cache Class Reference

Public Member Functions

 __construct ($sKey, $sModule, $oStrategy=null)
 
 cacheFileExists ($bTakeOffStatusIntoAccount=true)
 
 entryExists ($bTakeOffStatusIntoAccount=true)
 
 getFilePath ()
 
 getFileName ()
 
 getKey ()
 
 getModule ()
 
 getStrategy ()
 
 getModificationDate ()
 
 getAge ()
 
 isOutdated ($mOriginalFilePath)
 
 isOlderThan ($iTimestamp)
 
 ageIsMoreThan ($iSeconds=0, $iMinutes=0, $iHours=0, $iDays=0)
 
 fileSize ()
 
 size ()
 
 passContents ($bOutputContentLength=false)
 
 getContentsAsString ()
 
 getContentsAsVariable ()
 
 setContents ($mContents, $bForceSerialize=false, $bAppend=false)
 
 sendCacheControlHeaders ($iTimestamp=null)
 
 cacheIsOffForWriting ()
 
 cacheIsOff ()
 

Static Public Member Functions

static clearAllCaches ()
 

Detailed Description

Represents one file in the cache, identified by the dirname and the key (generated/caches/<dir>/<md5(key)>.cache).

Member Function Documentation

Cache::ageIsMoreThan (   $iSeconds = 0,
  $iMinutes = 0,
  $iHours = 0,
  $iDays = 0 
)

Convenience function for isOlderThan; takes a relative time and computes an absolute timestamp

Cache::cacheFileExists (   $bTakeOffStatusIntoAccount = true)

Returns true if a file representing this cache entry already exists, false otherwise

Deprecated:
use cacheEntryExists
Cache::cacheIsOff ( )

Returns true if, for whatever reason, no data should be read from the cache. This returns true if either The cache is off for writing The request parameter nocache is set The cache-control headers are set to no-cache (i.e. the user forced a-super reload in the browser)

Cache::cacheIsOffForWriting ( )

Returns true if, for whatever reason, no data should be written to the cache. This can be triggered by the general->caching boolean setting in config.yml Caching of config files is always on (because it is there that this setting is defined)

static Cache::clearAllCaches ( )
static

Removes all cache files but not their parent directories.

Cache::entryExists (   $bTakeOffStatusIntoAccount = true)

Returns true if this cache entry already exists, false otherwise

Cache::fileSize ( )

Gets the size of the cache file without reading the contents

Deprecated:
use size()
Cache::getAge ( )

Returns the age of the cached contents in seconds

Cache::getContentsAsString ( )

Gets the raw (possibly binary) contents of the cache file

Cache::getContentsAsVariable ( )

Returns the cached contents if they were not a string when saving

Cache::getFileName ( )

Returns the md5()’ed cache key.

Deprecated:
use md5(getKey()) or $oCache->getStrategy()->encodedKey($oCache)
Cache::getFilePath ( )

Returns the full path to the cache file. Note that this file may not yet exist

Deprecated:
only works if caching strategy is CachingStrategyFile. Use $oCache->getStrategy()->getFilePath($oCache)
Cache::getKey ( )

Returns the cache key.

Cache::getModificationDate ( )

Returns the cached content's modification date. Note that this will possibly result in an error if the cache entry does not (yet) exist

Cache::getModule ( )

Returns the cache module.

Cache::getStrategy ( )

Returns the caching strategy used.

Cache::isOlderThan (   $iTimestamp)

Compares the timestamp of the cached contents to the given timestamp and returns true if the cached contents are older, false otherwise

Cache::isOutdated (   $mOriginalFilePath)

Looks if the cached contents are older than the modified dates of any of the given files Pass a ResourceFinder instance rather than an array to prevent the (potentially expensive) call to ResourceFinder->find() in production.

Parameters
string | array | ResourceFinder$mOriginalFilePath
Cache::passContents (   $bOutputContentLength = false)

Outputs the raw contents directly to the client

Cache::sendCacheControlHeaders (   $iTimestamp = null)

Sends the cache control headers Last-Modified and ETag Uses the timestamp of the cache file as base for calculation. Additionally, this method exits if the client sent a matching If-None-Match or If-Modified-Since header You can call this method twice if you created a new cache file and don’t have any other timestamp. It will only output the headers once.

Parameters
$iTimestampdeprecated: to use this method without a cache file, call LinkUtil::sendCacheControlHeaders directly
Cache::setContents (   $mContents,
  $bForceSerialize = false,
  $bAppend = false 
)

Saves the cache file with the given contents. If value is a string, the data is saved to the file in raw, serialized otherwise

Cache::size ( )

Gets the size of the cache contents without reading the contents. May return null if unknown.


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