Class Zend_Cache_Backend_File

Description

Implements interfaces:

  • copyright: Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  • license: New BSD License

Located in /Cache/Backend/File.php (line 40)

Zend_Cache_Backend
   |
   --Zend_Cache_Backend_File
Variable Summary
Method Summary
 void __construct ([ $options = array()])
 boolean clean ([string $mode = Zend_Cache::CLEANING_MODE_ALL], [tags $tags = array()])
 array getCapabilities ()
 array getIds ()
 array getIdsMatchingAnyTags ([array $tags = array()])
 array getIdsMatchingTags ([array $tags = array()])
 array getIdsNotMatchingTags ([array $tags = array()])
 array getMetadatas (string $id)
 array getTags ()
 string|false load (string $id, [boolean $doNotTestCacheValidity = false])
 boolean remove (string $id)
 boolean save (string $data, string $id, [array $tags = array()], [int $specificLifetime = false])
 void setCacheDir (string $value, [boolean $trailingSeparator = true])
 mixed test (string $id)
 boolean touch (string $id, int $extraLifetime)
 boolean _clean (string $dir, [string $mode = Zend_Cache::CLEANING_MODE_ALL], [array $tags = array()])
 void _cleanMetadatas ()
 boolean _delMetadatas (string $id)
 int _expireTime ( $lifetime)
 string _file (string $id)
 string _fileGetContents (string $file)
 string _fileNameToId (string $fileName)
 boolean _filePutContents (string $file, string $string)
 void _get ( $dir,  $mode, [ $tags = array()])
 array|false _getMetadatas (string $id)
 string _hash (string $data, string $controlType)
 string _idToFileName (string $id)
 boolean _isMetadatasFile (string $fileName)
 array|false _loadMetadatas (string $id)
 string _metadatasFile (string $id)
 string _path (string $id, [boolean $parts = false])
 boolean _recursiveMkdirAndChmod (string $id)
 boolean _remove (string $file)
 boolean _saveMetadatas (string $id, array $metadatas)
 boolean _setMetadatas (string $id, array $metadatas, [boolean $save = true])
 boolean|mixed _test (string $id, boolean $doNotTestCacheValidity)
 void ___expire (string $id)
Variables
array $_metadatasArray = array() (line 107)

Array of metadatas (each item is an associative array)

  • access: protected
array $_options = array(
'cache_dir' => null,
'file_locking' => true,
'read_control' => true,
'read_control_type' => 'crc32',
'hashed_directory_level' => 0,
'hashed_directory_umask' => 0700,
'file_name_prefix' => 'zend_cache',
'cache_file_umask' => 0600,
'metadatas_array_max_size' => 100
)
(line 90)

Available options

=====> (string) cache_dir :

  • Directory where to put the cache files
=====> (boolean) file_locking :
  • Enable / disable file_locking
  • Can avoid cache corruption under bad circumstances but it doesn't work on multithread
webservers and on NFS filesystems for example

=====> (boolean) read_control :

  • Enable / disable read control
  • If enabled, a control key is embeded in cache file and this key is compared with the one
calculated after the reading.

=====> (string) read_control_type :

  • Type of read control (only if read control is enabled). Available values are : 'md5' for a md5 hash control (best but slowest) 'crc32' for a crc32 hash control (lightly less safe but faster, better choice) 'adler32' for an adler32 hash control (excellent choice too, faster than crc32) 'strlen' for a length only test (fastest)
=====> (int) hashed_directory_level :
  • Hashed directory level
  • Set the hashed directory structure level. 0 means "no hashed directory
structure", 1 means "one level of directory", 2 means "two levels"... This option can speed up the cache only when you have many thousands of cache file. Only specific benchs can help you to choose the perfect value for you. Maybe, 1 or 2 is a good start.

=====> (int) hashed_directory_umask :

  • Umask for hashed directory structure
=====> (string) file_name_prefix :
  • prefix for cache files
  • be really carefull with this option because a too generic value in a system cache dir (like /tmp) can cause disasters when cleaning the cache
=====> (int) cache_file_umask :
  • Umask for cache files
=====> (int) metatadatas_array_max_size :
  • max size for the metadatas array (don't change this value unless you know what you are doing)

  • var: available options
  • access: protected

Redefinition of:
Zend_Cache_Backend::$_options
Available options

Inherited Variables

Inherited from Zend_Cache_Backend

Zend_Cache_Backend::$_directives
Methods
Constructor __construct (line 117)

Constructor

  • throws: Zend_Cache_Exception
  • access: public
void __construct ([ $options = array()])
  • array $options: associative array of options

Redefinition of:
Zend_Cache_Backend::__construct()
Constructor
clean (line 284)

Clean some cache records

Available modes are : 'all' (default) => remove all cache entries ($tags is not used) 'old' => remove too old cache entries ($tags is not used) 'matchingTag' => remove cache entries matching all given tags ($tags can be an array of strings or a single string) 'notMatchingTag' => remove cache entries not matching one of the given tags ($tags can be an array of strings or a single string) 'matchingAnyTag' => remove cache entries matching any given tags ($tags can be an array of strings or a single string)

  • return: true if no problem
  • access: public
boolean clean ([string $mode = Zend_Cache::CLEANING_MODE_ALL], [tags $tags = array()])
  • string $mode: clean mode
  • tags $tags: array $tags array of tags

Implementation of:
Zend_Cache_Backend_Interface::clean()
Clean some cache records
getCapabilities (line 440)

Return an associative array of capabilities (booleans) of the backend

The array must include these keys :

  • automatic_cleaning (is automating cleaning necessary)
  • tags (are tags supported)
  • expired_read (is it possible to read expired cache records (for doNotTestCacheValidity option for example))
  • priority does the backend deal with priority when saving
  • infinite_lifetime (is infinite lifetime can work with this backend)
  • get_list (is it possible to get the list of cache ids and the complete list of tags)

  • return: associative of with capabilities
  • access: public
array getCapabilities ()

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getCapabilities()
Return an associative array of capabilities (booleans) of the backend
getFillingPercentage (line 356)

Return the filling percentage of the backend storage

  • return: integer between 0 and 100
  • throws: Zend_Cache_Exception
  • access: public
int getFillingPercentage ()

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getFillingPercentage()
Return the filling percentage of the backend storage
getIds (line 296)

Return an array of stored cache ids

  • return: array of stored cache ids (string)
  • access: public
array getIds ()

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getIds()
Return an array of stored cache ids
getIdsMatchingAnyTags (line 345)

Return an array of stored cache ids which match any given tags

In case of multiple tags, a logical AND is made between tags

  • return: array of any matching cache ids (string)
  • access: public
array getIdsMatchingAnyTags ([array $tags = array()])
  • array $tags: array of tags

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getIdsMatchingAnyTags()
Return an array of stored cache ids which match any given tags
getIdsMatchingTags (line 319)

Return an array of stored cache ids which match given tags

In case of multiple tags, a logical AND is made between tags

  • return: array of matching cache ids (string)
  • access: public
array getIdsMatchingTags ([array $tags = array()])
  • array $tags: array of tags

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getIdsMatchingTags()
Return an array of stored cache ids which match given tags
getIdsNotMatchingTags (line 332)

Return an array of stored cache ids which don't match given tags

In case of multiple tags, a logical OR is made between tags

  • return: array of not matching cache ids (string)
  • access: public
array getIdsNotMatchingTags ([array $tags = array()])
  • array $tags: array of tags

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getIdsNotMatchingTags()
Return an array of stored cache ids which don't match given tags
getMetadatas (line 381)

Return an array of metadatas for the given cache id

The array must include these keys :

  • expire : the expire timestamp
  • tags : a string array of tags
  • mtime : timestamp of last modification time

  • return: array of metadatas (false if the cache id is not found)
  • access: public
array getMetadatas (string $id)
  • string $id: cache id

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getMetadatas()
Return an array of metadatas for the given cache id
getTags (line 306)

Return an array of stored tags

  • return: array of stored tags (string)
  • access: public
array getTags ()

Implementation of:
Zend_Cache_Backend_ExtendedInterface::getTags()
Return an array of stored tags
load (line 173)

Test if a cache is available for the given id and (if yes) return it (false else)

  • return: cached datas
  • access: public
string|false load (string $id, [boolean $doNotTestCacheValidity = false])
  • string $id: cache id
  • boolean $doNotTestCacheValidity: if set to true, the cache validity won't be tested

Implementation of:
Zend_Cache_Backend_Interface::load()
Test if a cache is available for the given id and (if yes) return it (false else)
remove (line 259)

Remove a cache record

  • return: true if no problem
  • access: public
boolean remove (string $id)
  • string $id: cache id

Implementation of:
Zend_Cache_Backend_Interface::remove()
Remove a cache record
save (line 219)

Save some string datas into a cache record

Note : $data is always "string" (serialization is done by the core not by the backend)

  • return: true if no problem
  • access: public
boolean save (string $data, string $id, [array $tags = array()], [int $specificLifetime = false])
  • string $data: Datas to cache
  • string $id: Cache id
  • array $tags: Array of strings, the cache record will be tagged by each string entry
  • int $specificLifetime: If != false, set a specific lifetime for this cache record (null => infinite lifetime)

Implementation of:
Zend_Cache_Backend_Interface::save()
Save some string datas into a cache record
setCacheDir (line 151)

Set the cache_dir (particular case of setOption() method)

  • throws: Zend_Cache_Exception
  • access: public
void setCacheDir (string $value, [boolean $trailingSeparator = true])
  • string $value
  • boolean $trailingSeparator: If true, add a trailing separator is necessary
test (line 201)

Test if a cache is available or not (for the given id)

  • return: false (a cache is not available) or "last modified" timestamp (int) of the available cache record
  • access: public
mixed test (string $id)
  • string $id: cache id

Implementation of:
Zend_Cache_Backend_Interface::test()
Test if a cache is available or not (for the given id)
touch (line 404)

Give (if possible) an extra lifetime to the given cache id

  • return: true if ok
  • access: public
boolean touch (string $id, int $extraLifetime)
  • string $id: cache id
  • int $extraLifetime

Implementation of:
Zend_Cache_Backend_ExtendedInterface::touch()
Give (if possible) an extra lifetime to the given cache id
_clean (line 641)

Clean some cache records (protected method used for recursive stuff)

Available modes are : Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags ($tags can be an array of strings or a single string) Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} ($tags can be an array of strings or a single string) Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags ($tags can be an array of strings or a single string)

  • return: True if no problem
  • throws: Zend_Cache_Exception
  • access: protected
boolean _clean (string $dir, [string $mode = Zend_Cache::CLEANING_MODE_ALL], [array $tags = array()])
  • string $dir: Directory to clean
  • string $mode: Clean mode
  • array $tags: Array of tags
_cleanMetadatas (line 532)

Clear the metadatas array

  • access: protected
void _cleanMetadatas ()
_delMetadatas (line 518)

Drop a metadata record

  • return: True if no problem
  • access: protected
boolean _delMetadatas (string $id)
  • string $id: Cache id
_expireTime (line 823)

Compute & return the expire time

  • return: expire time (unix timestamp)
  • access: protected
int _expireTime ( $lifetime)
  • $lifetime
_file (line 874)

Make and return a file name (with path)

  • return: File name (with path)
  • access: protected
string _file (string $id)
  • string $id: Cache id
_fileGetContents (line 953)

Return the file content of the given file

  • return: File content (or false if problem)
  • access: protected
string _fileGetContents (string $file)
  • string $file: File complete path
_fileNameToId (line 1000)

Transform a file name into cache id and return it

  • return: Cache id
  • access: protected
string _fileNameToId (string $fileName)
  • string $fileName: File name
_filePutContents (line 976)

Put the given string into the given file

  • return: true if no problem
  • access: protected
boolean _filePutContents (string $file, string $string)
  • string $file: File complete path
  • string $string: String to put in file
_get (line 734)
  • access: protected
void _get ( $dir,  $mode, [ $tags = array()])
  • $dir
  • $mode
  • $tags
_getMetadatas (line 474)

Get a metadatas record

  • return: Associative array of metadatas
  • access: protected
array|false _getMetadatas (string $id)
  • string $id: Cache id
_hash (line 839)

Make a control key with the string containing datas

  • return: Control key
  • throws: Zend_Cache_Exception
  • access: protected
string _hash (string $data, string $controlType)
  • string $data: Data
  • string $controlType: Type of control 'md5', 'crc32' or 'strlen'
_idToFileName (line 861)

Transform a cache id into a file name and return it

  • return: File name
  • access: protected
string _idToFileName (string $id)
  • string $id: Cache id
_isMetadatasFile (line 590)

Check if the given filename is a metadatas one

  • return: True if it's a metadatas one
  • access: protected
boolean _isMetadatasFile (string $fileName)
  • string $fileName: File name
_loadMetadatas (line 543)

Load metadatas from disk

  • return: Metadatas associative array
  • access: protected
array|false _loadMetadatas (string $id)
  • string $id: Cache id
_metadatasFile (line 577)

Make and return a file name (with path) for metadatas

  • return: Metadatas file name (with path)
  • access: protected
string _metadatasFile (string $id)
  • string $id: Cache id
_path (line 888)

Return the complete directory path of a filename (including hashedDirectoryStructure)

  • return: Complete directory path
  • access: protected
string _path (string $id, [boolean $parts = false])
  • string $id: Cache id
  • boolean $parts: if true, returns array of directory parts instead of single string
_recursiveMkdirAndChmod (line 913)

Make the directory strucuture for the given id

  • return: true
  • access: protected
boolean _recursiveMkdirAndChmod (string $id)
  • string $id: cache id
_remove (line 609)

Remove a file

If we can't remove the file (because of locks or any problem), we will touch the file to invalidate it

  • return: True if ok
  • access: protected
boolean _remove (string $file)
  • string $file: Complete file path
_saveMetadatas (line 561)

Save metadatas to disk

  • return: True if no problem
  • access: protected
boolean _saveMetadatas (string $id, array $metadatas)
  • string $id: Cache id
  • array $metadatas: Associative array
_setMetadatas (line 496)

Set a metadatas record

  • return: True if no problem
  • access: protected
boolean _setMetadatas (string $id, array $metadatas, [boolean $save = true])
  • string $id: Cache id
  • array $metadatas: Associative array of metadatas
  • boolean $save: optional pass false to disable saving to file
_test (line 935)

Test if the given cache id is available (and still valid as a cache record)

  • return: false (a cache is not available) or "last modified" timestamp (int) of the available cache record
  • access: protected
boolean|mixed _test (string $id, boolean $doNotTestCacheValidity)
  • string $id: Cache id
  • boolean $doNotTestCacheValidity: If set to true, the cache validity won't be tested
___expire (line 459)

PUBLIC METHOD FOR UNIT TESTING ONLY !

Force a cache record to expire

  • access: public
void ___expire (string $id)
  • string $id: cache id

Inherited Methods

Inherited From Zend_Cache_Backend

 Zend_Cache_Backend::__construct()
 Zend_Cache_Backend::getLifetime()
 Zend_Cache_Backend::getTmpDir()
 Zend_Cache_Backend::isAutomaticCleaningAvailable()
 Zend_Cache_Backend::setDirectives()
 Zend_Cache_Backend::setOption()
 Zend_Cache_Backend::_isGoodTmpDir()
 Zend_Cache_Backend::_log()
 Zend_Cache_Backend::_loggerSanity()

Documentation generated on Mon, 21 Jun 2010 15:23:18 -0400 by phpDocumentor 1.4.3