Extension:PhpTags Wiki/Reference/WCache

The WCache class manages the cache of page rendering.

Note Note: static methods and properties works with the objects of current page
class WCache {

/*
 * Constants
 */

    // Time when current page was generated
    const DateTime CACHE_TIME;

    // Time when current page was generated
    const string CACHE_TIME_STRING;

/*
 * Static properties
 */

    // The number of seconds after which cache of current page should expire
    static int $cacheExpiry;

/*
 * Methods
 */

    // Set a flag in current page indicating that the content is dynamic and shouldn't be cached
    static disableCache();
}

Constants

edit
CACHE_TIME
Time when this page was rendered. Returns DateTime object and it will cause an error if nothing provides DateTime object. DateTime object may be provided by the PhpTags Functions extension.
CACHE_TIME_STRING
Time when this page was rendered.

Static properties

edit

cacheExpiry

edit
    static int $cacheExpiry;
Description

The number of seconds after which cache of current page should expire If set to a value greater than a value previously set, the new assignment has no effect.

  Note: Setting WCache::$cacheExpiry does not work properly due to bug 67997
Get

Returns a value smaller or equal to the smallest number assigned to WCache::$cacheExpiry.

Set

The number of seconds.

Methods

edit

disableCache

edit
    static WCache::disableCache();
Description

Set a flag in the page renderings cache indicating that the content is dynamic and shouldn't be cached.

Examples

edit
Example 1
<phptag>
WCache::disableCache();
echo "This page never get cached and always get updated.\n\n";
echo 'UUID is <span style="color:red;">' . UUID . '</span> now';
</phptag>

demo