public class Cacheable

class.cacheable.php #14

The Cacheable class provides a wrapper around an iCache interface and provides basic CRUD functionality for caching. Historically, this class was hardcoded to use MySQL, but since Symphony 2.4 this may not be the case anymore.

Methods

void __construct(iCache $cacheProvider)

The constructor for the Cacheable takes an instance of the a class that extends the iCache interface. Symphony::Database() is accepted a valid $cacheProvider to maintain backwards compatibility.

Parameters
  • $cacheProvider iCacheIf a Symphony::Database() is provided, the constructor will create a CacheDatabase interface. If null, or the $cacheProvider is not a class that implements iCache or iNamespacedCache interface an InvalidArgumentException will be thrown.

mixed check(string $hash)
Parameters
  • $hash stringThe hash of the Cached object, as defined by the user

Deprecated

This function will be removed in Symphony 3.0. Use read() instead.

boolean clean()
Deprecated

This function will be removed in Symphony 3.0. Use delete() instead.

static 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

Parameters
  • $data stringThe data to compress

Returns

The compressed data, or false if an error occurred

static string|boolean decompressData(string $data)

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

Parameters
  • $data stringThe data to decompress

Returns

The decompressed data, or false if an error occurred

boolean delete(string $hash, string $namespace)

Given the hash, this function will remove it from the cache.

Parameters
  • $hash stringThe user defined hash of the data

  • $namespace stringDelete multiple items by a namespace

boolean forceExpiry(string $hash)
Parameters
  • $hash stringThe user defined hash of the data

Deprecated

This function will be removed in Symphony 3.0. Use delete() instead.

string getType()

Returns the type of the internal caching provider

mixed read(string $hash, string $namespace)

Given the hash of a some data, check to see whether it exists the cache.

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

  • $namespace stringRead multiple items by a namespace

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

A wrapper for writing data in the cache.

Parameters
  • $hash stringA

  • $data stringThe data to be cached

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

  • $namespace stringWrite an item and save in a namespace for ease of bulk operations later

Returns

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

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