Tuskfish API V1.1.2
  • Package
  • Class

Packages

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

Classes

  • TfCache
  • TfFileHandler
  • TfLogger
  • TfMetadata
  • TfPaginationControl
  • TfPreference
  • TfPreferenceHandler
  • TfTemplate
  • TfTree

Traits

  • TfLanguage
  • TfMagicMethods
  • TfMimetypes
  • TfRights

Functions

  • checkPasswordStrength
  • hashPassword
  • tf_autoload
  • tfContentModuleAutoload

Class TfCache

Handles Tuskfish page-level caching operations.

Cached pages are written to the private cache directory(trust_path/cache). The cache can be enabled / disabled and a expiry timer set in Tuskfish preferences.

Package: core
Copyright: Simon Wilkinson 2013+ (https://tuskfish.biz)
License: GNU General Public License (GPL) V2
Author: Simon Wilkinson simon@isengard.biz
Version: Release: 1.1
Since: 1.0
Var: TfishValidator $validator An instance of the Tuskfish data validator class.
Var: TfPreference $preference An instance of the Tuskfish site preferences class.
Located at trust_path/libraries/tuskfish/class/TfCache.php

Methods summary

public
# __construct( TfValidator $validator, TfPreference $preference )

Constructor.

Constructor.

Parameters

$validator
An instance of the Tuskfish data validator class.
$preference
An instance of the Tuskfish site preferences class.
public
# cachePage( 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 tfFooter.php, before ob_end_flush(). Note that warnings are suppressed when trying to open the file. The query parameters are important to retrieve the precise representation of the page requested, since they change its state.

Parameters

$basename

Filename of this page (without extension), 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 boolean
# flushCache( )

Clear the private cache.

Clear the private cache.

The entire cache will be cleared. This method is called if a single object is added, edited or destroyed to ensure that index pages and pagination controls stay up to date.

Returns

boolean
True on success, false on failure.
public string|boolean
# getCachedPage( 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 controller script execution will simply proceed and tfFooter.php will request the page be written to cache, assuming that caching is enabled. This function should be called after tfHeader.php is included.

Parameters

$basename

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

$params
URL Query string parameters for this page as $key => $value pairs.

Returns

string|boolean
Return cached page if exists, otherwise false.

Properties summary

protected $validator
#
protected $preference
#
Tuskfish API V1.1.2 API documentation generated by ApiGen