symfony API

sfCache Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.2 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.2 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

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

Method Summary

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

Method Details

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

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

    Cleans the cache.

    returns true if no problem

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

    $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

  • (object The) getBackend () Browse code

    Gets the backend object.

    returns backend object

  • (int) getLastModified ($key) Browse code

    $key The cache key

    Returns the last modification date of the given key.

    returns The last modified time

  • (integer) getLifetime ($lifetime) Browse code

    $lifetime Lifetime in seconds

    Computes lifetime.

    returns Lifetime in seconds

  • (array) getMany ($keys) Browse code

    $keys An array of keys

    Gets many keys at once.

    returns An associative array of data from cache

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

    $name The option name
    $default The default value

    Gets an option value.

    returns The option value

  • (int) getTimeout ($key) Browse code

    $key The cache key

    Returns the timeout for the given key.

    returns The timeout time

  • (Boolean) has ($key) Browse code

    $key The cache key

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

    returns true if the cache exists, false otherwise

  • initialize ($options = array()) Browse code

    $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.

  • (string) patternToRegexp ($pattern) Browse code

    $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

  • (Boolean) remove ($key) Browse code

    $key The cache key

    Removes a content from the cache.

    returns true if no problem

  • (Boolean) removePattern ($pattern) Browse code

    $pattern The cache key pattern

    Removes content from the cache that matches the given pattern.

    returns true if no problem

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

    $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

  • setOption ($name, $value) Browse code

    $name The option name
    $value The option value

    Sets an option value.

  • __construct ($options = array()) Browse code

    $options

    Class constructor.