symfony API

sfCache Class

« Back to API menu

Packages

You are currently browsing the symfony API for the 1.2 version. Switch to:

sfCache is an abstract class for all cache classes in symfony.

Method Summary

  • __construct($options = array())
    Class constructor.
  • Boolean removePattern($pattern)
    Removes content from the cache that matches the given pattern.
  • int getTimeout($key)
    Returns the timeout for the given key.
  • initialize($options = array())
    Initializes this sfCache instance.
  • mixed get($key, $default = null)
    Gets the cache content for a given key.
  • integer getLifetime($lifetime)
    Computes lifetime.
  • string patternToRegexp($pattern)
    Converts a pattern to a regular expression.
  • object The getBackend()
    Gets the backend object.
  • Boolean remove($key)
    Removes a content from the cache.
  • Boolean set($key, $data, $lifetime = null)
    Saves some data in the cache.
  • Boolean clean($mode = self::ALL)
    Cleans the cache.
  • int getLastModified($key)
    Returns the last modification date of the given key.
  • mixed getOption($name, $default = null)
    Gets an option value.
  • Boolean has($key)
    Returns true if there is a cache for the given key.
  • array getMany($keys)
    Gets many keys at once.
  • setOption($name, $value)
    Sets an option value.

Method Details

  • __construct ($options = array())

    $options

    Class constructor.

  • (Boolean) removePattern ($pattern)

    $pattern The cache key pattern

    Removes content from the cache that matches the given pattern.

    returns true if no problem

  • (int) getTimeout ($key)

    $key The cache key

    Returns the timeout for the given key.

    returns The timeout time

  • initialize ($options = array())

    $options

    An array of options.

    Available options:

    * automatic_cleaning_factor: The automatic cleaning process destroy too old (for the given life time) (default value: 1000) cache files when a new cache file is written.

  • => no automatic cache cleaning

  • => systematic cache cleaning

  • x (integer) > 1 => automatic cleaning randomly 1 times on x cache write

    * lifetime (optional): The default life time (default value: 86400)

    Initializes this sfCache instance.

    throws sfInitializationException If an error occurs while initializing this sfCache instance.

  • (mixed) get ($key, $default = null)

    $key The cache key
    $default The default value is the key does not exist or not valid anymore

    Gets the cache content for a given key.

    returns The data of the cache

  • (integer) getLifetime ($lifetime)

    $lifetime Lifetime in seconds

    Computes lifetime.

    returns Lifetime in seconds

  • (string) patternToRegexp ($pattern)

    $pattern A pattern

    Converts a pattern to a regular expression.

    A pattern can use some special characters:


    • * Matches a namespace (foo:*:bar)

    • ** Matches one or more namespaces (foo:**:bar)


    returns A regular expression

  • (object The) getBackend ()

    Gets the backend object.

    returns backend object

  • (Boolean) remove ($key)

    $key The cache key

    Removes a content from the cache.

    returns true if no problem

  • (Boolean) set ($key, $data, $lifetime = null)

    $key The cache key
    $data The data to put in cache
    $lifetime The lifetime

    Saves some data in the cache.

    returns true if no problem

  • (Boolean) clean ($mode = self::ALL)

    $mode The clean mode sfCache::ALL: remove all keys (default) sfCache::OLD: remove all expired keys

    Cleans the cache.

    returns true if no problem

  • (int) getLastModified ($key)

    $key The cache key

    Returns the last modification date of the given key.

    returns The last modified time

  • (mixed) getOption ($name, $default = null)

    $name The option name
    $default The default value

    Gets an option value.

    returns The option value

  • (Boolean) has ($key)

    $key The cache key

    Returns true if there is a cache for the given key.

    returns true if the cache exists, false otherwise

  • (array) getMany ($keys)

    $keys An array of keys

    Gets many keys at once.

    returns An associative array of data from cache

  • setOption ($name, $value)

    $name The option name
    $value The option value

    Sets an option value.