public class Cacheable

class.cacheable.php #15

The Cacheable class is used to store data in the dedicated Symphony cache table. It is used by Symphony for Session management and by the Dynamic XML datasource, but it can be used by extensions to store anything. The cache table is tbl_cache


void __construct(MySQL $Database)

The constructor for the Cacheable takes an instance of the MySQL class and assigns it to $this->Database

  • $Database MySQLAn instance of the MySQL class to store the cached data in.

array|boolean check(string $hash)

Given the hash of a some data, check to see whether it exists in tbl_cache. If no cached object is found, this function will return false, otherwise the cached object will be returned as an array.

  • $hash stringThe hash of the Cached object, as defined by the user


An associative array of the cached object including the creation time, expiry time, the hash and the data. If the object is not found, false will be returned.

void clean()

Removes all cache objects from tbl_cache that have expired. After removing, the function uses the optimise function

See Also
string|boolean compressData(string $data)

Given some data, this function will compress it using gzcompress and then the result is run through base64_encode If this fails, false is returned otherwise the compressed data

  • $data stringThe data to compress


The compressed data, or false if an error occurred

string|boolean decompressData(string $data)

Given compressed data, this function will decompress it and return the output.

  • $data stringThe data to decompress


The decompressed data, or false if an error occurred

void forceExpiry(string $hash)

Given the hash of a cacheable object, remove it from tbl_cache regardless of if it has expired or not.

  • $hash stringThe hash of the Cached object, as defined by the user

boolean write(string $hash, string $data, integer $ttl)

This function will compress data for storage in tbl_cache. It is left to the user to define a unique hash for this data so that it can be retrieved in the future. Optionally, a $ttl parameter can be passed for this data. If this is omitted, it data is considered to be valid forever. This function utilizes the Mutex class to act as a crude locking mechanism.

  • $hash stringThe hash of the Cached object, as defined by the user

  • $data stringThe data to be cached, this will be compressed prior to saving.

  • $ttl integerA integer representing how long the data should be valid for in minutes. By default this is null, meaning the data is valid forever


If an error occurs, this function will return false otherwise true

See Also

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details