symfony API

sfFileCache Class

« Back to API menu

action

addon

cache

config

controller

countable

database

debug

exception

filter

generator

helper

i18n

log

request

response

storage

test

user

util

validator

view

You are currently browsing the symfony documentation for the 1.0 version. Switch to:

Cache class that stores content in files.

Inheritence

sfFunctionCache  <  sfFileCache  <  sfCache

Method Summary

  • __construct($cacheDir = null)
    Constructor.
  • string hash($data)
    Makes a control key with the string containing datas.
  • setSuffix($suffix)
    Sets the suffix for cache files.
  • boolean getFileLocking()
    Gets the value of the fileLocking option.
  • setWriteControl($boolean)
    Enables / disables write control.
  • boolean writeAndControl($path, $file, $data)
    Writes the given data in the cache file and controls it just after to avoid corrupted cache entries.
  • string read($path, $file)
    Reads the cache file and returns the content.
  • setFileLocking($boolean)
    Enables / disables file locking.
  • initialize($options = array())
    Initializes the cache.
  • string get($id, $namespace = self::DEFAULT_NAMESPACE, $doNotTestCacheValidity = false)
    Tests if a cache is available and (if yes) returns it.
  • boolean remove($id, $namespace = self::DEFAULT_NAMESPACE)
    Removes a cache file.
  • boolean set($id, $namespace = self::DEFAULT_NAMESPACE, $data)
    Saves some data in a cache file.
  • boolean clean($namespace = null, $mode = &apos;all&apos;)
    Cleans the cache.
  • boolean cleanDir($dir, $mode, 2)
    Recursive function for cleaning cache file in the given directory.
  • getCacheDir()
  • array getFileName($id, $namespace)
    Makes a file name (with path).
  • boolean unlink($file)
    Removes a file.
  • boolean getWriteControl()
    Gets the value of the writeControl option.
  • int lastModified($id, $namespace = self::DEFAULT_NAMESPACE)
    Returns the cache last modification time.
  • boolean has($id, $namespace = self::DEFAULT_NAMESPACE, $doNotTestCacheValidity = false)
    Returns true if there is a cache for the given id and namespace.
  • boolean write($path, $file, $data)
    Writes the given data in the cache file.
  • setCacheDir($cacheDir)
    Sets the cache root directory.

Methods inherited from sfCache

setLifeTime , get , getLifeTime , remove , set , clean , lastModified , has

Method Details

  • __construct ($cacheDir = null)

    $cacheDir The cache root directory

    Constructor.

  • (string) hash ($data)

    $data data

    Makes a control key with the string containing datas.

    returns control key

  • setSuffix ($suffix)

    $suffix The suffix name (with the leading .)

    Sets the suffix for cache files.

  • (boolean) getFileLocking ()

    Gets the value of the fileLocking option.

  • setWriteControl ($boolean)

    Enables / disables write control.

  • (boolean) writeAndControl ($path, $file, $data)

    $path The file path
    $file The file name
    $data The data to put in cache

    Writes the given data in the cache file and controls it just after to avoid corrupted cache entries.

    returns true if the test is ok

  • (string) read ($path, $file)

    $path The file path
    $file The file name

    Reads the cache file and returns the content.

    returns The content of the cache file.

    throws sfCacheException

  • setFileLocking ($boolean)

    Enables / disables file locking.

  • initialize ($options = array())

    $options An array of options Available options:
    • cacheDir: cache root directory

    • fileLocking: enable / disable file locking (boolean)

    • writeControl: enable / disable write control (boolean)

    • readControl: enable / disable read control (boolean)

    • fileNameProtection: enable / disable automatic file name protection (boolean)

    • automaticCleaningFactor: disable / tune automatic cleaning process (int)

    • hashedDirectoryLevel: level of the hashed directory system (int)

    • lifeTime: default life time

    Initializes the cache.

  • (string) get ($id, $namespace = self::DEFAULT_NAMESPACE, $doNotTestCacheValidity = false)

    $id The cache id
    $namespace The name of the cache namespace
    $doNotTestCacheValidity If set to true, the cache validity won't be tested

    Tests if a cache is available and (if yes) returns it.

    returns Data of the cache (or null if no cache available)

  • (boolean) remove ($id, $namespace = self::DEFAULT_NAMESPACE)

    $id The cache id
    $namespace The name of the cache namespace

    Removes a cache file.

    returns true if no problem

  • (boolean) set ($id, $namespace = self::DEFAULT_NAMESPACE, $data)

    $id The cache id
    $namespace The name of the cache namespace
    $data The data to put in cache

    Saves some data in a cache file.

    returns true if no problem

  • (boolean) clean ($namespace = null, $mode = &apos;all&apos;)

    $namespace The name of the cache namespace

    Cleans the cache.

    If no namespace is specified all cache files will be destroyed else only cache files of the specified namespace will be destroyed.

    returns true if no problem

  • (boolean) cleanDir ($dir, $mode, 2)

    $dir The directory complete path
    $mode The name of the cache namespace
    2 The flush cache mode : 'old', 'all'

    Recursive function for cleaning cache file in the given directory.

    returns true if no problem

    throws sfCacheException

  • getCacheDir ()

  • (array) getFileName ($id, $namespace)

    $id The cache id
    $namespace The name of the namespace

    Makes a file name (with path).

    returns An array containing the path and the file name

  • (boolean) unlink ($file)

    $file The complete file path and name

    Removes a file.

    returns true if no problem

  • (boolean) getWriteControl ()

    Gets the value of the writeControl option.

  • (int) lastModified ($id, $namespace = self::DEFAULT_NAMESPACE)

    Returns the cache last modification time.

    returns The last modification time

  • (boolean) has ($id, $namespace = self::DEFAULT_NAMESPACE, $doNotTestCacheValidity = false)

    $id The cache id
    $namespace The name of the cache namespace
    $doNotTestCacheValidity If set to true, the cache validity won't be tested

    Returns true if there is a cache for the given id and namespace.

    returns true if the cache exists, false otherwise

  • (boolean) write ($path, $file, $data)

    $path The file path
    $file The file name
    $data The data to put in cache

    Writes the given data in the cache file.

    returns true if ok

    throws sfCacheException

  • setCacheDir ($cacheDir)

    $cacheDir The directory where to put the cache files

    Sets the cache root directory.