Tuskfish API
  • Package
  • Class

Packages

  • content
  • core
  • database
  • installation
  • security
  • user
  • utilities

Classes

  • TfishAncestralObject
  • TfishAngryTree
  • TfishCache
  • TfishFileHandler
  • TfishLogger
  • TfishPreference
  • TfishPreferenceHandler

Functions

  • tfish_autoload

Class TfishCache

Handles Tuskfish cache operations.

The cache can be enabled / disabled and expiry timer set in Tuskfish preferences.

Package: core
Copyright: Simon Wilkinson 2013-2017 (https://tuskfish.biz)
License: GNU General Public License (GPL) V2
Author: Simon Wilkinson simon@isengard.biz
Version: Release: 1.0
Since: 1.0
Located at trust_path/libraries/tuskfish/class/TfishCache.php

Methods summary

public static
# checkCache( TfishPreference $tfish_preference, string $basename, array $params = array() )

Check if a cached page exists and has not expired, and displays it.

Check if a cached page exists and has not expired, and displays it.

You should only pass in parameters that you were expecting and had explicitly whitelisted and have already validated. Gating the parameters in this way reduces the opportunity for exploitation.

Note that only alphanumeric and underscore characters are permitted in the basename parameter; this is to avoid directory traversals.

If a cached page is not available execution will simply proceed and tfish_footer.php will request the page be written to cache. This function should be called after tfish_header.php is included.

Parameters

$tfish_preference
TfishPreference object, to make site preferences available.
$basename

Page filename without extension, eg. 'article' (alphanumeric and underscore characters only).

$params
URL Query string parameters for this page as $key => $value pairs.
public static
# cachePage( TfishPreference $tfish_preference, string $basename, array $params, string $buffer )

Save a copy of this page to the cache directory.

Save a copy of this page to the cache directory.

This function should be called in tfish_footer.php, before ob_end_flush(). Note that warnings are suppressed when trying to open the file.

Parameters

$tfish_preference

TfishPreference object, to make the site preferences available.

$basename
Filename of this page, alphanumeric and underscore characters only.
$params
URL Query string parameters for this page as $key => $value pairs.
$buffer
HTML page output from ob_get_contents().
public static boolean
# flushCache( )

Clear the private cache.

Clear the private cache.

At the moment this is something of a blunt instrument; the entire cache will be cleared if a single object is added, edited or destroyed (this is to ensure that index pages and pagination controls stay up to date). Later it would be good to be more selective.

Returns

boolean
True on success, false on failure.
Tuskfish API API documentation generated by ApiGen